svghmi/widget_animate.ysl2
branchsvghmi
changeset 3059 e0db3f6a5f39
parent 3058 6ea4b7e1a9ed
child 3062 9ec338a99a18
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/svghmi/widget_animate.ysl2	Thu Sep 24 11:52:40 2020 +0200
@@ -0,0 +1,35 @@
+// widget_animate.ysl2
+
+template "widget[@type='Animate']", mode="widget_class"{
+    ||
+    class AnimateWidget extends Widget{
+        frequency = 5;
+        speed = 0;
+
+        dispatch(value) {
+            this.speed = value;
+
+            //reconfigure animation
+            this.request_animate();
+        }
+
+        animate(){
+           // change animation properties
+           this.element.children[0].setAttribute("dur", String(this.speed)+"s")
+        }
+
+        init() {
+             let width = this.element.getAttribute("width");
+             let height = this.element.getAttribute("height");
+             this.element.setAttribute("x",width/-2);
+             this.element.setAttribute("y",height/-2);
+        }
+    }
+    ||
+}
+
+
+template "widget[@type='Animate']", mode="widget_defs" {
+    param "hmi_element";
+    |,
+}