author | Edouard Tisserant <edouard.tisserant@gmail.com> |
Sun, 21 Feb 2021 21:38:44 +0100 | |
branch | svghmi |
changeset 3155 | 99ce78ddd353 |
parent 3151 | 8e5d383a58cb |
child 3178 | 21cb76012c78 |
permissions | -rw-r--r-- |
3136
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
1 |
// widget_scrollbar.ysl2 |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
2 |
|
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
3 |
template "widget[@type='ScrollBar']", mode="widget_class"{ |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
4 |
|| |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
5 |
class ScrollBarWidget extends Widget{ |
3139
1f5ca646ce6e
SVGHMI: Add inhibition to widget's apply_hmi_value() so that it does not change variable more frquently than given widget's frequency. This prevents flooding network with many update if browser is producing events at high rate, as for exemple when dragging ScrollBar's cursor.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3138
diff
changeset
|
6 |
frequency = 10; |
3136
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
7 |
position = undefined; |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
8 |
range = undefined; |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
9 |
size = undefined; |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
10 |
mincursize = 0.1; |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
11 |
|
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
12 |
dispatch(value,oldval, index) { |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
13 |
switch(index) { |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
14 |
case 0: |
3143
8388e6d4aa61
SVGHMI: more straightforward implementation of dragging position computation in Scrollbar + some little fix about boundaries.
Edouard Tisserant
parents:
3139
diff
changeset
|
15 |
this.position = value; |
3136
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
16 |
break; |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
17 |
case 1: |
3143
8388e6d4aa61
SVGHMI: more straightforward implementation of dragging position computation in Scrollbar + some little fix about boundaries.
Edouard Tisserant
parents:
3139
diff
changeset
|
18 |
this.range = Math.max(1,value); |
3136
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
19 |
break; |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
20 |
case 2: |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
21 |
this.size = value; |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
22 |
break; |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
23 |
} |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
24 |
|
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
25 |
this.request_animate(); |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
26 |
} |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
27 |
|
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
28 |
get_ratios() { |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
29 |
let range = this.range; |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
30 |
let size = Math.max(this.range * this.mincursize, Math.min(this.size, range)); |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
31 |
let maxh = this.range_elt.height.baseVal.value; |
3151
8e5d383a58cb
SVGHMI: Fixed HMI:ScrollBar to exclude cursor size from accessible range ( position is now 0->range-size instead of 0->range ). Fixed and extended tests/svghmi to have working ScrollBar on two alarm pages. Includes generated XSLT update.
Edouard Tisserant
parents:
3143
diff
changeset
|
32 |
let pixels = maxh; |
8e5d383a58cb
SVGHMI: Fixed HMI:ScrollBar to exclude cursor size from accessible range ( position is now 0->range-size instead of 0->range ). Fixed and extended tests/svghmi to have working ScrollBar on two alarm pages. Includes generated XSLT update.
Edouard Tisserant
parents:
3143
diff
changeset
|
33 |
let units = range; |
3136
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
34 |
return [size, maxh, range, pixels, units]; |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
35 |
} |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
36 |
|
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
37 |
animate(){ |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
38 |
if(this.position == undefined || this.range == undefined || this.size == undefined) |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
39 |
return; |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
40 |
let [size, maxh, range, pixels, units] = this.get_ratios(); |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
41 |
|
3151
8e5d383a58cb
SVGHMI: Fixed HMI:ScrollBar to exclude cursor size from accessible range ( position is now 0->range-size instead of 0->range ). Fixed and extended tests/svghmi to have working ScrollBar on two alarm pages. Includes generated XSLT update.
Edouard Tisserant
parents:
3143
diff
changeset
|
42 |
let new_y = this.range_elt.y.baseVal.value + Math.round(Math.min(this.position,range-size) * pixels / units); |
3136
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
43 |
let new_height = Math.round(maxh * size/range); |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
44 |
|
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
45 |
this.cursor_elt.y.baseVal.value = new_y; |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
46 |
this.cursor_elt.height.baseVal.value = new_height; |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
47 |
} |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
48 |
|
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
49 |
init_mandatory() { |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
50 |
this.cursor_elt.onpointerdown = () => this.on_cursor_down(); |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
51 |
|
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
52 |
this.bound_drag = this.drag.bind(this); |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
53 |
this.bound_drop = this.drop.bind(this); |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
54 |
} |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
55 |
|
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
56 |
apply_position(position){ |
3151
8e5d383a58cb
SVGHMI: Fixed HMI:ScrollBar to exclude cursor size from accessible range ( position is now 0->range-size instead of 0->range ). Fixed and extended tests/svghmi to have working ScrollBar on two alarm pages. Includes generated XSLT update.
Edouard Tisserant
parents:
3143
diff
changeset
|
57 |
this.position = Math.round(Math.max(Math.min(position, this.range - this.size), 0)); |
3143
8388e6d4aa61
SVGHMI: more straightforward implementation of dragging position computation in Scrollbar + some little fix about boundaries.
Edouard Tisserant
parents:
3139
diff
changeset
|
58 |
this.apply_hmi_value(0, this.position); |
3136
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
59 |
} |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
60 |
|
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
61 |
on_page_click(is_up){ |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
62 |
this.apply_position(is_up ? this.position-this.size |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
63 |
: this.position+this.size); |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
64 |
} |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
65 |
|
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
66 |
on_cursor_down(e){ |
3138
1d724e8d5592
SVGHMI: fix scrollbar not behaving when rotated.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3137
diff
changeset
|
67 |
// get scrollbar -> root transform |
1d724e8d5592
SVGHMI: fix scrollbar not behaving when rotated.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3137
diff
changeset
|
68 |
let ctm = this.range_elt.getCTM(); |
1d724e8d5592
SVGHMI: fix scrollbar not behaving when rotated.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3137
diff
changeset
|
69 |
// relative motion -> discard translation |
1d724e8d5592
SVGHMI: fix scrollbar not behaving when rotated.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3137
diff
changeset
|
70 |
ctm.e = 0; |
1d724e8d5592
SVGHMI: fix scrollbar not behaving when rotated.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3137
diff
changeset
|
71 |
ctm.f = 0; |
1d724e8d5592
SVGHMI: fix scrollbar not behaving when rotated.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3137
diff
changeset
|
72 |
// root -> scrollbar transform |
1d724e8d5592
SVGHMI: fix scrollbar not behaving when rotated.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3137
diff
changeset
|
73 |
this.invctm = ctm.inverse(); |
3136
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
74 |
svg_root.addEventListener("pointerup", this.bound_drop, true); |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
75 |
svg_root.addEventListener("pointermove", this.bound_drag, true); |
3143
8388e6d4aa61
SVGHMI: more straightforward implementation of dragging position computation in Scrollbar + some little fix about boundaries.
Edouard Tisserant
parents:
3139
diff
changeset
|
76 |
this.dragpos = this.position; |
3136
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
77 |
} |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
78 |
|
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
79 |
drop(e) { |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
80 |
svg_root.removeEventListener("pointerup", this.bound_drop, true); |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
81 |
svg_root.removeEventListener("pointermove", this.bound_drag, true); |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
82 |
} |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
83 |
|
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
84 |
drag(e) { |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
85 |
let [size, maxh, range, pixels, units] = this.get_ratios(); |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
86 |
if(pixels == 0) return; |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
87 |
let point = new DOMPoint(e.movementX, e.movementY); |
3138
1d724e8d5592
SVGHMI: fix scrollbar not behaving when rotated.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3137
diff
changeset
|
88 |
let movement = point.matrixTransform(this.invctm).y; |
3143
8388e6d4aa61
SVGHMI: more straightforward implementation of dragging position computation in Scrollbar + some little fix about boundaries.
Edouard Tisserant
parents:
3139
diff
changeset
|
89 |
this.dragpos += movement * units / pixels; |
8388e6d4aa61
SVGHMI: more straightforward implementation of dragging position computation in Scrollbar + some little fix about boundaries.
Edouard Tisserant
parents:
3139
diff
changeset
|
90 |
this.apply_position(this.dragpos); |
3136
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
91 |
} |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
92 |
} |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
93 |
|| |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
94 |
} |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
95 |
|
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
96 |
template "widget[@type='ScrollBar']", mode="widget_defs" { |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
97 |
param "hmi_element"; |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
98 |
labels("cursor range"); |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
99 |
|
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
100 |
const "pagebuttons" optional_labels("pageup pagedown"); |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
101 |
const "have_pagebuttons","string-length($pagebuttons)>0"; |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
102 |
value "$pagebuttons"; |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
103 |
|
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
104 |
| init: function() { |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
105 |
| this.init_mandatory(); |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
106 |
|
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
107 |
if "$have_pagebuttons" { |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
108 |
| this.pageup_elt.onclick = () => this.on_page_click(true); |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
109 |
| this.pagedown_elt.onclick = () => this.on_page_click(false); |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
110 |
} |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
111 |
| }, |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
112 |
} |