author | Edouard Tisserant <edouard.tisserant@gmail.com> |
Mon, 03 May 2021 00:04:08 +0200 | |
branch | svghmi |
changeset 3235 | b2b6bf45aa2d |
parent 3232 | 7bdb766c2a4d |
child 3241 | fe945f1f48b7 |
permissions | -rw-r--r-- |
3064
4b44d09c48a7
- New widget customHtml which allows to insert block of html code
usveticic
parents:
3062
diff
changeset
|
1 |
// widget_animaterotation.ysl2 |
2944 | 2 |
|
3232
7bdb766c2a4d
SVGHMI: In order to allow widget signature and description to coexist in same ysl2 file, introduced widget_class, widget_defs to declare widget codegen templates and gen_index_xhtml to mark templates that are only usefull in gen_index_xhtml.xslt.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3064
diff
changeset
|
3 |
widget_class("AnimateRotation") { |
3009 | 4 |
|| |
5 |
frequency = 5; |
|
3059
e0db3f6a5f39
Button and toggle reworked to use animate and dispatch
usveticic
parents:
3058
diff
changeset
|
6 |
speed = 0; |
3062 | 7 |
widget_center = undefined; |
3009 | 8 |
|
3056
827bf284feec
Button, ToggleButton and slider updated. Error to warning when building
usveticic
parents:
3024
diff
changeset
|
9 |
dispatch(value) { |
3062 | 10 |
this.speed = value / 5; |
3059
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 |
3062 | 18 |
for(let child of this.element.children){ |
19 |
if(child.nodeName == "animateTransform"){ |
|
20 |
if(this.speed > 0){ |
|
21 |
child.setAttribute("dur", this.speed+"s"); |
|
22 |
child.setAttribute("from", "0 "+this.widget_center[0]+" "+this.widget_center[1]); |
|
23 |
child.setAttribute("to", "360 "+this.widget_center[0]+" "+this.widget_center[1]); |
|
24 |
} |
|
25 |
else if(this.speed < 0){ |
|
26 |
child.setAttribute("dur", (-1)*this.speed+"s"); |
|
27 |
child.setAttribute("from", "360 "+this.widget_center[0]+" "+this.widget_center[1]); |
|
28 |
child.setAttribute("to", "0 "+this.widget_center[0]+" "+this.widget_center[1]); |
|
29 |
} |
|
30 |
else{ |
|
31 |
child.setAttribute("from", "0 "+this.widget_center[0]+" "+this.widget_center[1]); |
|
32 |
child.setAttribute("to", "0 "+this.widget_center[0]+" "+this.widget_center[1]); |
|
33 |
} |
|
34 |
} |
|
35 |
} |
|
3059
e0db3f6a5f39
Button and toggle reworked to use animate and dispatch
usveticic
parents:
3058
diff
changeset
|
36 |
} |
3009 | 37 |
|
3059
e0db3f6a5f39
Button and toggle reworked to use animate and dispatch
usveticic
parents:
3058
diff
changeset
|
38 |
init() { |
3062 | 39 |
let widget_pos = this.element.getBBox(); |
40 |
this.widget_center = [(widget_pos.x+widget_pos.width/2), (widget_pos.y+widget_pos.height/2)]; |
|
3059
e0db3f6a5f39
Button and toggle reworked to use animate and dispatch
usveticic
parents:
3058
diff
changeset
|
41 |
} |
3009 | 42 |
|| |
3024 | 43 |
} |
3009 | 44 |
|
45 |
||
3232
7bdb766c2a4d
SVGHMI: In order to allow widget signature and description to coexist in same ysl2 file, introduced widget_class, widget_defs to declare widget codegen templates and gen_index_xhtml to mark templates that are only usefull in gen_index_xhtml.xslt.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3064
diff
changeset
|
46 |
widget_defs("AnimateRotation") { |
2976
99c4521bb844
SVGHMI: Changed widget button handler to element attribute.
dgaberscek
parents:
2961
diff
changeset
|
47 |
param "hmi_element"; |
3009 | 48 |
|, |
3000
a9a45977bac0
SVGHMI: prefer apply_hmi_value() to change_hmi_value() when possible
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2976
diff
changeset
|
49 |
} |