Raspsnir/public_html/browserquest/js/transition.js

1 line
837 B
JavaScript
Raw Permalink Normal View History

define([],function(){var e=Class.extend({init:function(){this.startValue=0,this.endValue=0,this.duration=0,this.inProgress=!1},start:function(e,t,n,r,i,s){this.startTime=e,this.updateFunction=t,this.stopFunction=n,this.startValue=r,this.endValue=i,this.duration=s,this.inProgress=!0,this.count=0},step:function(e){if(this.inProgress)if(this.count>0)this.count-=1,log.debug(e+": jumped frame");else{var t=e-this.startTime;t>this.duration&&(t=this.duration);var n=this.endValue-this.startValue,r=this.startValue+n/this.duration*t;r=Math.round(r),t===this.duration||r===this.endValue?(this.stop(),this.stopFunction&&this.stopFunction()):this.updateFunction&&this.updateFunction(r)}},restart:function(e,t,n){this.start(e,this.updateFunction,this.stopFunction,t,n,this.duration),this.step(e)},stop:function(){this.inProgress=!1}});return e});