--- a/svghmi/widget_animate.ysl2 Thu Oct 01 14:23:27 2020 +0200
+++ b/svghmi/widget_animate.ysl2 Mon Oct 19 09:29:11 2020 +0200
@@ -5,6 +5,7 @@
class AnimateWidget extends Widget{
frequency = 5;
speed = 0;
+ start = false;
widget_center = undefined;
dispatch(value) {
@@ -17,20 +18,21 @@
animate(){
// change animation properties
for(let child of this.element.children){
- if(child.nodeName == "animateTransform"){
+ if(child.nodeName.startsWith("animate")){
+ if(this.speed != 0 && !this.start){
+ this.start = true;
+ this.element.beginElement();
+ }
+
if(this.speed > 0){
child.setAttribute("dur", this.speed+"s");
- child.setAttribute("from", "0 "+this.widget_center[0]+" "+this.widget_center[1]);
- child.setAttribute("to", "360 "+this.widget_center[0]+" "+this.widget_center[1]);
}
else if(this.speed < 0){
child.setAttribute("dur", (-1)*this.speed+"s");
- child.setAttribute("from", "360 "+this.widget_center[0]+" "+this.widget_center[1]);
- child.setAttribute("to", "0 "+this.widget_center[0]+" "+this.widget_center[1]);
}
else{
- child.setAttribute("from", "0 "+this.widget_center[0]+" "+this.widget_center[1]);
- child.setAttribute("to", "0 "+this.widget_center[0]+" "+this.widget_center[1]);
+ this.start = false;
+ this.element.endElement();
}
}
}