usveticic@3059: // widget_animate.ysl2 dgaberscek@2944: edouard@3232: widget_class("Animate") { usveticic@3009: || usveticic@3009: frequency = 5; usveticic@3059: speed = 0; usveticic@3064: start = false; usveticic@3062: widget_center = undefined; usveticic@3009: usveticic@3056: dispatch(value) { usveticic@3062: this.speed = value / 5; usveticic@3059: usveticic@3059: //reconfigure animation usveticic@3059: this.request_animate(); usveticic@3056: } usveticic@3056: usveticic@3059: animate(){ usveticic@3059: // change animation properties usveticic@3062: for(let child of this.element.children){ usveticic@3064: if(child.nodeName.startsWith("animate")){ usveticic@3064: if(this.speed != 0 && !this.start){ usveticic@3064: this.start = true; usveticic@3064: this.element.beginElement(); usveticic@3064: } usveticic@3064: usveticic@3062: if(this.speed > 0){ usveticic@3062: child.setAttribute("dur", this.speed+"s"); usveticic@3062: } usveticic@3062: else if(this.speed < 0){ usveticic@3062: child.setAttribute("dur", (-1)*this.speed+"s"); usveticic@3062: } usveticic@3062: else{ usveticic@3064: this.start = false; usveticic@3064: this.element.endElement(); usveticic@3062: } usveticic@3062: } usveticic@3062: } usveticic@3059: } usveticic@3009: usveticic@3059: init() { usveticic@3062: let widget_pos = this.element.getBBox(); usveticic@3062: this.widget_center = [(widget_pos.x+widget_pos.width/2), (widget_pos.y+widget_pos.height/2)]; usveticic@3059: } usveticic@3009: || Edouard@3024: } usveticic@3009: