equal
deleted
inserted
replaced
3 template "widget[@type='Animate']", mode="widget_class"{ |
3 template "widget[@type='Animate']", mode="widget_class"{ |
4 || |
4 || |
5 class AnimateWidget extends Widget{ |
5 class AnimateWidget extends Widget{ |
6 frequency = 5; |
6 frequency = 5; |
7 speed = 0; |
7 speed = 0; |
|
8 start = false; |
8 widget_center = undefined; |
9 widget_center = undefined; |
9 |
10 |
10 dispatch(value) { |
11 dispatch(value) { |
11 this.speed = value / 5; |
12 this.speed = value / 5; |
12 |
13 |
15 } |
16 } |
16 |
17 |
17 animate(){ |
18 animate(){ |
18 // change animation properties |
19 // change animation properties |
19 for(let child of this.element.children){ |
20 for(let child of this.element.children){ |
20 if(child.nodeName == "animateTransform"){ |
21 if(child.nodeName.startsWith("animate")){ |
|
22 if(this.speed != 0 && !this.start){ |
|
23 this.start = true; |
|
24 this.element.beginElement(); |
|
25 } |
|
26 |
21 if(this.speed > 0){ |
27 if(this.speed > 0){ |
22 child.setAttribute("dur", this.speed+"s"); |
28 child.setAttribute("dur", this.speed+"s"); |
23 child.setAttribute("from", "0 "+this.widget_center[0]+" "+this.widget_center[1]); |
|
24 child.setAttribute("to", "360 "+this.widget_center[0]+" "+this.widget_center[1]); |
|
25 } |
29 } |
26 else if(this.speed < 0){ |
30 else if(this.speed < 0){ |
27 child.setAttribute("dur", (-1)*this.speed+"s"); |
31 child.setAttribute("dur", (-1)*this.speed+"s"); |
28 child.setAttribute("from", "360 "+this.widget_center[0]+" "+this.widget_center[1]); |
|
29 child.setAttribute("to", "0 "+this.widget_center[0]+" "+this.widget_center[1]); |
|
30 } |
32 } |
31 else{ |
33 else{ |
32 child.setAttribute("from", "0 "+this.widget_center[0]+" "+this.widget_center[1]); |
34 this.start = false; |
33 child.setAttribute("to", "0 "+this.widget_center[0]+" "+this.widget_center[1]); |
35 this.element.endElement(); |
34 } |
36 } |
35 } |
37 } |
36 } |
38 } |
37 } |
39 } |
38 |
40 |