12 lines
4.9 KiB
JavaScript
12 lines
4.9 KiB
JavaScript
//>>built
|
|
define("dojo/_base/fx","./kernel ./config ./lang ../Evented ./Color ../aspect ../sniff ../dom ../dom-style".split(" "),function(r,x,e,y,k,m,z,t,n){var l=e.mixin,c={},u=c._Line=function(a,b){this.start=a;this.end=b};u.prototype.getValue=function(a){return(this.end-this.start)*a+this.start};var g=c.Animation=function(a){l(this,a);e.isArray(this.curve)&&(this.curve=new u(this.curve[0],this.curve[1]))};g.prototype=new y;e.extend(g,{duration:350,repeat:0,rate:20,_percent:0,_startRepeatCount:0,_getStep:function(){var a=
|
|
this._percent,b=this.easing;return b?b(a):a},_fire:function(a,b){b=b||[];if(this[a])if(x.debugAtAllCosts)this[a].apply(this,b);else try{this[a].apply(this,b)}catch(A){console.error("exception in animation handler for:",a),console.error(A)}return this},play:function(a,b){this._delayTimer&&this._clearTimer();if(b)this._stopTimer(),this._active=this._paused=!1,this._percent=0;else if(this._active&&!this._paused)return this;this._fire("beforeBegin",[this.node]);a=a||this.delay;b=e.hitch(this,"_play",
|
|
b);if(0<a)return this._delayTimer=setTimeout(b,a),this;b();return this},_play:function(a){this._delayTimer&&this._clearTimer();this._startTime=(new Date).valueOf();this._paused&&(this._startTime-=this.duration*this._percent);this._active=!0;this._paused=!1;a=this.curve.getValue(this._getStep());this._percent||(this._startRepeatCount||(this._startRepeatCount=this.repeat),this._fire("onBegin",[a]));this._fire("onPlay",[a]);this._cycle();return this},pause:function(){this._delayTimer&&this._clearTimer();
|
|
this._stopTimer();if(!this._active)return this;this._paused=!0;this._fire("onPause",[this.curve.getValue(this._getStep())]);return this},gotoPercent:function(a,b){this._stopTimer();this._active=this._paused=!0;this._percent=a;b&&this.play();return this},stop:function(a){this._delayTimer&&this._clearTimer();if(!this._timer)return this;this._stopTimer();a&&(this._percent=1);this._fire("onStop",[this.curve.getValue(this._getStep())]);this._active=this._paused=!1;return this},status:function(){return this._active?
|
|
this._paused?"paused":"playing":"stopped"},_cycle:function(){if(this._active){var a=(new Date).valueOf(),a=0===this.duration?1:(a-this._startTime)/this.duration;1<=a&&(a=1);this._percent=a;this.easing&&(a=this.easing(a));this._fire("onAnimate",[this.curve.getValue(a)]);1>this._percent?this._startTimer():(this._active=!1,0<this.repeat?(this.repeat--,this.play(null,!0)):-1==this.repeat?this.play(null,!0):this._startRepeatCount&&(this.repeat=this._startRepeatCount,this._startRepeatCount=0),this._percent=
|
|
0,this._fire("onEnd",[this.node]),!this.repeat&&this._stopTimer())}return this},_clearTimer:function(){clearTimeout(this._delayTimer);delete this._delayTimer}});var p=0,q=null,v={run:function(){}};e.extend(g,{_startTimer:function(){this._timer||(this._timer=m.after(v,"run",e.hitch(this,"_cycle"),!0),p++);q||(q=setInterval(e.hitch(v,"run"),this.rate))},_stopTimer:function(){this._timer&&(this._timer.remove(),this._timer=null,p--);0>=p&&(clearInterval(q),q=null,p=0)}});var B=z("ie")?function(a){var b=
|
|
a.style;b.width.length||"auto"!=n.get(a,"width")||(b.width="auto")}:function(){};c._fade=function(a){a.node=t.byId(a.node);var b=l({properties:{}},a);a=b.properties.opacity={};a.start="start"in b?b.start:function(){return+n.get(b.node,"opacity")||0};a.end=b.end;a=c.animateProperty(b);m.after(a,"beforeBegin",e.partial(B,b.node),!0);return a};c.fadeIn=function(a){return c._fade(l({end:1},a))};c.fadeOut=function(a){return c._fade(l({end:0},a))};c._defaultEasing=function(a){return.5+Math.sin((a+1.5)*
|
|
Math.PI)/2};var w=function(a){this._properties=a;for(var b in a){var e=a[b];e.start instanceof k&&(e.tempColor=new k)}};w.prototype.getValue=function(a){var b={},c;for(c in this._properties){var h=this._properties[c],f=h.start;f instanceof k?b[c]=k.blendColors(f,h.end,a,h.tempColor).toCss():e.isArray(f)||(b[c]=(h.end-f)*a+f+("opacity"!=c?h.units||"px":0))}return b};c.animateProperty=function(a){var b=a.node=t.byId(a.node);a.easing||(a.easing=r._defaultEasing);a=new g(a);m.after(a,"beforeBegin",e.hitch(a,
|
|
function(){var a={},c;for(c in this.properties){var f=function(a,b){var c={height:a.offsetHeight,width:a.offsetWidth}[b];if(void 0!==c)return c;c=n.get(a,b);return"opacity"==b?+c:g?c:parseFloat(c)};if("width"==c||"height"==c)this.node.display="block";var d=this.properties[c];e.isFunction(d)&&(d=d(b));d=a[c]=l({},e.isObject(d)?d:{end:d});e.isFunction(d.start)&&(d.start=d.start(b));e.isFunction(d.end)&&(d.end=d.end(b));var g=0<=c.toLowerCase().indexOf("color");"end"in d?"start"in d||(d.start=f(b,c)):
|
|
d.end=f(b,c);g?(d.start=new k(d.start),d.end=new k(d.end)):d.start="opacity"==c?+d.start:parseFloat(d.start)}this.curve=new w(a)}),!0);m.after(a,"onAnimate",e.hitch(n,"set",a.node),!0);return a};c.anim=function(a,b,e,h,f,d){return c.animateProperty({node:a,duration:e||g.prototype.duration,properties:b,easing:h,onEnd:f}).play(d||0)};l(r,c);r._Animation=g;return c});
|
|
//# sourceMappingURL=fx.js.map
|