author | Edouard Tisserant <edouard.tisserant@gmail.com> |
Wed, 21 Feb 2024 18:26:46 +0100 | |
changeset 3899 | 31b0f3468175 |
parent 3232 | 7bdb766c2a4d |
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 |
|
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("Animate") { |
3009 | 4 |
|| |
5 |
frequency = 5; |
|
3059
e0db3f6a5f39
Button and toggle reworked to use animate and dispatch
usveticic
parents:
3058
diff
changeset
|
6 |
speed = 0; |
3064
4b44d09c48a7
- New widget customHtml which allows to insert block of html code
usveticic
parents:
3062
diff
changeset
|
7 |
start = false; |
3062 | 8 |
widget_center = undefined; |
3009 | 9 |
|
3056
827bf284feec
Button, ToggleButton and slider updated. Error to warning when building
usveticic
parents:
3024
diff
changeset
|
10 |
dispatch(value) { |
3062 | 11 |
this.speed = value / 5; |
3059
e0db3f6a5f39
Button and toggle reworked to use animate and dispatch
usveticic
parents:
3058
diff
changeset
|
12 |
|
e0db3f6a5f39
Button and toggle reworked to use animate and dispatch
usveticic
parents:
3058
diff
changeset
|
13 |
//reconfigure animation |
e0db3f6a5f39
Button and toggle reworked to use animate and dispatch
usveticic
parents:
3058
diff
changeset
|
14 |
this.request_animate(); |
3056
827bf284feec
Button, ToggleButton and slider updated. Error to warning when building
usveticic
parents:
3024
diff
changeset
|
15 |
} |
827bf284feec
Button, ToggleButton and slider updated. Error to warning when building
usveticic
parents:
3024
diff
changeset
|
16 |
|
3059
e0db3f6a5f39
Button and toggle reworked to use animate and dispatch
usveticic
parents:
3058
diff
changeset
|
17 |
animate(){ |
e0db3f6a5f39
Button and toggle reworked to use animate and dispatch
usveticic
parents:
3058
diff
changeset
|
18 |
// change animation properties |
3062 | 19 |
for(let child of this.element.children){ |
3064
4b44d09c48a7
- New widget customHtml which allows to insert block of html code
usveticic
parents:
3062
diff
changeset
|
20 |
if(child.nodeName.startsWith("animate")){ |
4b44d09c48a7
- New widget customHtml which allows to insert block of html code
usveticic
parents:
3062
diff
changeset
|
21 |
if(this.speed != 0 && !this.start){ |
4b44d09c48a7
- New widget customHtml which allows to insert block of html code
usveticic
parents:
3062
diff
changeset
|
22 |
this.start = true; |
4b44d09c48a7
- New widget customHtml which allows to insert block of html code
usveticic
parents:
3062
diff
changeset
|
23 |
this.element.beginElement(); |
4b44d09c48a7
- New widget customHtml which allows to insert block of html code
usveticic
parents:
3062
diff
changeset
|
24 |
} |
4b44d09c48a7
- New widget customHtml which allows to insert block of html code
usveticic
parents:
3062
diff
changeset
|
25 |
|
3062 | 26 |
if(this.speed > 0){ |
27 |
child.setAttribute("dur", this.speed+"s"); |
|
28 |
} |
|
29 |
else if(this.speed < 0){ |
|
30 |
child.setAttribute("dur", (-1)*this.speed+"s"); |
|
31 |
} |
|
32 |
else{ |
|
3064
4b44d09c48a7
- New widget customHtml which allows to insert block of html code
usveticic
parents:
3062
diff
changeset
|
33 |
this.start = false; |
4b44d09c48a7
- New widget customHtml which allows to insert block of html code
usveticic
parents:
3062
diff
changeset
|
34 |
this.element.endElement(); |
3062 | 35 |
} |
36 |
} |
|
37 |
} |
|
3059
e0db3f6a5f39
Button and toggle reworked to use animate and dispatch
usveticic
parents:
3058
diff
changeset
|
38 |
} |
3009 | 39 |
|
3059
e0db3f6a5f39
Button and toggle reworked to use animate and dispatch
usveticic
parents:
3058
diff
changeset
|
40 |
init() { |
3062 | 41 |
let widget_pos = this.element.getBBox(); |
42 |
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
|
43 |
} |
3009 | 44 |
|| |
3024 | 45 |
} |
3009 | 46 |