svghmi/widget_animate.ysl2
author usveticic
Thu, 24 Sep 2020 11:52:40 +0200
branchsvghmi
changeset 3059 e0db3f6a5f39
parent 3058 svghmi/widget_button.ysl2@6ea4b7e1a9ed
child 3062 9ec338a99a18
permissions -rw-r--r--
Button and toggle reworked to use animate and dispatch
Slider added buttons to incremente/decrement by 1
Init for animate widget
Changed test svg and plc
// 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";
    |,
}