author | usveticic |
Thu, 24 Sep 2020 11:52:40 +0200 | |
branch | svghmi |
changeset 3059 | e0db3f6a5f39 |
parent 3058 | svghmi/widget_button.ysl2@6ea4b7e1a9ed |
child 3062 | 9ec338a99a18 |
permissions | -rw-r--r-- |
3059
e0db3f6a5f39
Button and toggle reworked to use animate and dispatch
usveticic
parents:
3058
diff
changeset
|
1 |
// widget_animate.ysl2 |
2944 | 2 |
|
3059
e0db3f6a5f39
Button and toggle reworked to use animate and dispatch
usveticic
parents:
3058
diff
changeset
|
3 |
template "widget[@type='Animate']", mode="widget_class"{ |
3009 | 4 |
|| |
3059
e0db3f6a5f39
Button and toggle reworked to use animate and dispatch
usveticic
parents:
3058
diff
changeset
|
5 |
class AnimateWidget extends Widget{ |
3009 | 6 |
frequency = 5; |
3059
e0db3f6a5f39
Button and toggle reworked to use animate and dispatch
usveticic
parents:
3058
diff
changeset
|
7 |
speed = 0; |
3009 | 8 |
|
3056
827bf284feec
Button, ToggleButton and slider updated. Error to warning when building
usveticic
parents:
3024
diff
changeset
|
9 |
dispatch(value) { |
3059
e0db3f6a5f39
Button and toggle reworked to use animate and dispatch
usveticic
parents:
3058
diff
changeset
|
10 |
this.speed = value; |
e0db3f6a5f39
Button and toggle reworked to use animate and dispatch
usveticic
parents:
3058
diff
changeset
|
11 |
|
e0db3f6a5f39
Button and toggle reworked to use animate and dispatch
usveticic
parents:
3058
diff
changeset
|
12 |
//reconfigure animation |
e0db3f6a5f39
Button and toggle reworked to use animate and dispatch
usveticic
parents:
3058
diff
changeset
|
13 |
this.request_animate(); |
3056
827bf284feec
Button, ToggleButton and slider updated. Error to warning when building
usveticic
parents:
3024
diff
changeset
|
14 |
} |
827bf284feec
Button, ToggleButton and slider updated. Error to warning when building
usveticic
parents:
3024
diff
changeset
|
15 |
|
3059
e0db3f6a5f39
Button and toggle reworked to use animate and dispatch
usveticic
parents:
3058
diff
changeset
|
16 |
animate(){ |
e0db3f6a5f39
Button and toggle reworked to use animate and dispatch
usveticic
parents:
3058
diff
changeset
|
17 |
// change animation properties |
e0db3f6a5f39
Button and toggle reworked to use animate and dispatch
usveticic
parents:
3058
diff
changeset
|
18 |
this.element.children[0].setAttribute("dur", String(this.speed)+"s") |
e0db3f6a5f39
Button and toggle reworked to use animate and dispatch
usveticic
parents:
3058
diff
changeset
|
19 |
} |
3009 | 20 |
|
3059
e0db3f6a5f39
Button and toggle reworked to use animate and dispatch
usveticic
parents:
3058
diff
changeset
|
21 |
init() { |
e0db3f6a5f39
Button and toggle reworked to use animate and dispatch
usveticic
parents:
3058
diff
changeset
|
22 |
let width = this.element.getAttribute("width"); |
e0db3f6a5f39
Button and toggle reworked to use animate and dispatch
usveticic
parents:
3058
diff
changeset
|
23 |
let height = this.element.getAttribute("height"); |
e0db3f6a5f39
Button and toggle reworked to use animate and dispatch
usveticic
parents:
3058
diff
changeset
|
24 |
this.element.setAttribute("x",width/-2); |
e0db3f6a5f39
Button and toggle reworked to use animate and dispatch
usveticic
parents:
3058
diff
changeset
|
25 |
this.element.setAttribute("y",height/-2); |
e0db3f6a5f39
Button and toggle reworked to use animate and dispatch
usveticic
parents:
3058
diff
changeset
|
26 |
} |
3009 | 27 |
} |
28 |
|| |
|
3024 | 29 |
} |
3009 | 30 |
|
31 |
||
3059
e0db3f6a5f39
Button and toggle reworked to use animate and dispatch
usveticic
parents:
3058
diff
changeset
|
32 |
template "widget[@type='Animate']", mode="widget_defs" { |
2976
99c4521bb844
SVGHMI: Changed widget button handler to element attribute.
dgaberscek
parents:
2961
diff
changeset
|
33 |
param "hmi_element"; |
3009 | 34 |
|, |
3000
a9a45977bac0
SVGHMI: prefer apply_hmi_value() to change_hmi_value() when possible
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2976
diff
changeset
|
35 |
} |