Skip to content
Browse files

Altered logic for firing `onend`

When _end is called, `onend` will fire unless `started = false`.
  • Loading branch information...
1 parent 4031c2b commit 8578e746adb1ab9b26d28e5aaac61522bcc5c3d2 @GarrettS committed
View
2 build/anim/Animation-min.js
@@ -1 +1 @@
-APE.namespace("APE.anim");(function(){APE.anim.Animation=E;var B="rationalValue";function E(H){if(typeof H=="number"){this.duration=H*1000}this.timeLimit=this.duration}function C(H){return H}E.prototype={paused:false,duration:1000,timeLimit:1000,isReversed:false,startOffset:0,endOffset:1,startValue:0,endValue:1,rationalValue:0,transition:C,position:0,onstart:C,onend:C,onabort:function(H){throw H},run:C,start:function(){if(this.paused){return}this.timeLimit=this.duration;this.endOffset=this.transition(this.endValue);this._start()},startAfter:function(H){var J=this;function I(){J.start();clearTimeout(this.startAfterTimer);delete J.startAfterTimer}J.startAfterTimer=setTimeout(I,H)},_start:function(){A.unregister(this);this._startTime=+new Date;this.onstart();A.register(this);this.started=true;this.playing=true;clearTimeout(this.startAfterTimer);delete this.startAfterTimer},seekTo:function(J,H){J=parseFloat(J);if(!isFinite(J)){return}if(J===this[B]){return}this.startOffset=this.position;this.startValue=this[B];this.endValue=J;var I=Math.abs(J-this.startValue);this.timeLimit=this.duration*I;this.isReversed=(J<this[B]);this._transitionBackwards=this.isReversed&&H;if(this._transitionBackwards){this.endOffset=1-this.transition(1-J)}else{this.endOffset=this.transition(J)}this._start()},toggleDirection:function(){if(!this.started){this.start();return}if(this.isReversed){this.seekTo(1)}else{this.seekTo(0,this.position==1)}},reset:function(){this.position=0;this.timeLimit=this.duration},pause:function(){if(this.paused||!this.playing){return}this.paused=true;this.elapsedTime=new Date-this._startTime;A.unregister(this)},resume:function(){if(!this.paused){return}this.paused=false;this._startTime=new Date-this.elapsedTime;A.register(this)},toString:function(){return"Animation {duration millis: "+this.duration+", position:"+this.position+"}"},stop:function(H){clearTimeout(this.startAfterTimer);delete this.startAfterTimer;this._end(H)},abort:function(H){A.unregister(this);this.onabort(H||{})},_end:function(H){this.playing=false;A.unregister(this);if(H!==false){this.onend()}}};var A=new function(){this.register=M;this.unregister=J;var O=17,N=[],P;function M(R){if(N.length===0){H.call(this)}for(var Q=0;Q<N.length;Q++){if(N[Q]===R){return}}N.push(R)}function J(R){for(var Q=0;Q<N.length;Q++){if(N[Q]===R){N.splice(Q,1)}}if(N.length===0){N=[];K.call(this)}}function H(){P=setInterval(I,O)}function I(){var R=0,S;for(;R<N.length;R++){try{S=N[R];L(S)}catch(Q){if(S){S.abort(Q)}}}}function K(){self.clearInterval(P)}function L(R){var Q=new Date-R._startTime;if(Q>=R.timeLimit){R.run(R.position=R.endOffset);R[B]=R.endValue;R._end();return}var S=Q/R.duration,T=R.transition;if(R.isReversed){R[B]=R.startValue-S;if(R._transitionBackwards){R.position=1-T(1-R[B])}else{R.position=T(R[B])}}else{R[B]=R.startValue+S;R.position=T(R[B])}if(typeof R.onplay=="function"){R.onplay(R.position)}R.run(R.position)}};var F=Math.PI,G=Math.atan,D=Math.cos;APE.anim.Transitions={none:C,accel:function(H){return H*H*H},decel:function(H){H=1-H;return 1-(H*H*H)},reverse:function(H){return 1-H},getSigmoid:function(I){I=I||1;return H;function H(J){return(G(I*(2*J-1))/G(I)+1)/(2)}},easeInEaseOut:function(H){return(G(H*F/1-F/2)+1)/2.0038848218538874},wobble:function(H){return(-D(3*H*F)/2)+0.5},loop:function(H){return(-D(2*H*F)/2)+0.5},spring:function(H){return 1-(D(H*4.5*F)*Math.exp(-H*6))},swingTo:function(I){var H=1.70158;return(I-=1)*I*((H+1)*I+H)+1},swingToFrom:function(I){var H=1.70158;if((I/=0.5)<1){return 0.5*(I*I*(((H*=(1.525))+1)*I-H))}return 0.5*((I-=2)*I*(((H*=(1.525))+1)*I+H)+2)}}})();
+APE.namespace("APE.anim");(function(){APE.anim.Animation=E;var B="rationalValue";function E(H){if(typeof H=="number"){this.duration=H*1000}this.timeLimit=this.duration}function C(H){return H}E.prototype={paused:false,duration:1000,timeLimit:1000,isReversed:false,startOffset:0,endOffset:1,startValue:0,endValue:1,rationalValue:0,transition:C,position:0,onstart:C,onend:C,onabort:function(H){throw H},run:C,start:function(){if(this.paused){return}this.timeLimit=this.duration;this.endOffset=this.transition(this.endValue);this._start()},startAfter:function(H){var J=this;function I(){J.start();clearTimeout(this.startAfterTimer);delete J.startAfterTimer}J.startAfterTimer=setTimeout(I,H)},_start:function(){A.unregister(this);this._startTime=+new Date;this.onstart();A.register(this);this.started=true;this.playing=true;clearTimeout(this.startAfterTimer);delete this.startAfterTimer},seekTo:function(J,H){J=parseFloat(J);if(!isFinite(J)){return}if(J===this[B]){return}this.startOffset=this.position;this.startValue=this[B];this.endValue=J;var I=Math.abs(J-this.startValue);this.timeLimit=this.duration*I;this.isReversed=(J<this[B]);this._transitionBackwards=this.isReversed&&H;if(this._transitionBackwards){this.endOffset=1-this.transition(1-J)}else{this.endOffset=this.transition(J)}this._start()},toggleDirection:function(){if(!this.started){this.start();return}if(this.isReversed){this.seekTo(1)}else{this.seekTo(0,this.position==1)}},reset:function(){this.position=0;this.timeLimit=this.duration;this.started=false},pause:function(){if(this.paused||!this.playing){return}this.paused=true;this.elapsedTime=new Date-this._startTime;A.unregister(this)},resume:function(){if(!this.paused){return}this.paused=false;this._startTime=new Date-this.elapsedTime;A.register(this)},toString:function(){return"Animation {duration millis: "+this.duration+", position:"+this.position+"}"},stop:function(){clearTimeout(this.startAfterTimer);delete this.startAfterTimer;this._end()},abort:function(H){A.unregister(this);this.onabort(H||{})},_end:function(){this.playing=false;A.unregister(this);if(this.started){this.onend()}}};var A=new function(){this.register=M;this.unregister=J;var O=17,N=[],P;function M(R){if(N.length===0){H.call(this)}for(var Q=0;Q<N.length;Q++){if(N[Q]===R){return}}N.push(R)}function J(R){for(var Q=0;Q<N.length;Q++){if(N[Q]===R){N.splice(Q,1)}}if(N.length===0){N=[];K.call(this)}}function H(){P=setInterval(I,O)}function I(){var R=0,S;for(;R<N.length;R++){try{S=N[R];L(S)}catch(Q){if(S){S.abort(Q)}}}}function K(){self.clearInterval(P)}function L(R){var Q=new Date-R._startTime;if(Q>=R.timeLimit){R.run(R.position=R.endOffset);R[B]=R.endValue;R._end();return}var S=Q/R.duration,T=R.transition;if(R.isReversed){R[B]=R.startValue-S;if(R._transitionBackwards){R.position=1-T(1-R[B])}else{R.position=T(R[B])}}else{R[B]=R.startValue+S;R.position=T(R[B])}if(typeof R.onplay=="function"){R.onplay(R.position)}R.run(R.position)}};var F=Math.PI,G=Math.atan,D=Math.cos;APE.anim.Transitions={none:C,accel:function(H){return H*H*H},decel:function(H){H=1-H;return 1-(H*H*H)},reverse:function(H){return 1-H},getSigmoid:function(I){I=I||1;return H;function H(J){return(G(I*(2*J-1))/G(I)+1)/(2)}},easeInEaseOut:function(H){return(G(H*F/1-F/2)+1)/2.0038848218538874},wobble:function(H){return(-D(3*H*F)/2)+0.5},loop:function(H){return(-D(2*H*F)/2)+0.5},spring:function(H){return 1-(D(H*4.5*F)*Math.exp(-H*6))},swingTo:function(I){var H=1.70158;return(I-=1)*I*((H+1)*I+H)+1},swingToFrom:function(I){var H=1.70158;if((I/=0.5)<1){return 0.5*(I*I*(((H*=(1.525))+1)*I-H))}return 0.5*((I-=2)*I*(((H*=(1.525))+1)*I+H)+2)}}})();
View
16 build/anim/Animation.js
@@ -234,11 +234,12 @@ APE.namespace("APE.anim");
},
/**
- * resets the animation to position 0.
+ * s the animation to position 0.
*/
reset : function() {
this.position = 0;
this.timeLimit = this.duration;
+ this.started = false;
},
/**
@@ -270,15 +271,11 @@ APE.namespace("APE.anim");
/**
* Ends the anim.
- *
- * @param {boolean} ended, if true, calls onend().
- * This is not a pause() method; calling stop()
- * then resume() will not cause the Animation to restart.
*/
- stop : function(ended) {
+ stop : function() {
clearTimeout(this.startAfterTimer);
delete this.startAfterTimer;
- this._end(ended);
+ this._end();
},
/** Cancels the anim where it is; does not call onend() */
@@ -287,11 +284,10 @@ APE.namespace("APE.anim");
this.onabort(ex || {});
},
- /** @protected - can use in subclass. */
- _end : function(complete) {
+ _end : function() {
this.playing = false;
Manager.unregister(this);
- if (complete !== false) {
+ if (this.started) {
this.onend();
}
}
View
2 build/anim/anim-min.js
@@ -1 +1 @@
-APE.namespace("APE.anim");(function(){APE.anim.Animation=E;var B="rationalValue";function E(H){if(typeof H=="number"){this.duration=H*1000}this.timeLimit=this.duration}function C(H){return H}E.prototype={paused:false,duration:1000,timeLimit:1000,isReversed:false,startOffset:0,endOffset:1,startValue:0,endValue:1,rationalValue:0,transition:C,position:0,onstart:C,onend:C,onabort:function(H){throw H},run:C,start:function(){if(this.paused){return}this.timeLimit=this.duration;this.endOffset=this.transition(this.endValue);this._start()},startAfter:function(H){var J=this;function I(){J.start();clearTimeout(this.startAfterTimer);delete J.startAfterTimer}J.startAfterTimer=setTimeout(I,H)},_start:function(){A.unregister(this);this._startTime=+new Date;this.onstart();A.register(this);this.started=true;this.playing=true;clearTimeout(this.startAfterTimer);delete this.startAfterTimer},seekTo:function(J,H){J=parseFloat(J);if(!isFinite(J)){return}if(J===this[B]){return}this.startOffset=this.position;this.startValue=this[B];this.endValue=J;var I=Math.abs(J-this.startValue);this.timeLimit=this.duration*I;this.isReversed=(J<this[B]);this._transitionBackwards=this.isReversed&&H;if(this._transitionBackwards){this.endOffset=1-this.transition(1-J)}else{this.endOffset=this.transition(J)}this._start()},toggleDirection:function(){if(!this.started){this.start();return}if(this.isReversed){this.seekTo(1)}else{this.seekTo(0,this.position==1)}},reset:function(){this.position=0;this.timeLimit=this.duration},pause:function(){if(this.paused||!this.playing){return}this.paused=true;this.elapsedTime=new Date-this._startTime;A.unregister(this)},resume:function(){if(!this.paused){return}this.paused=false;this._startTime=new Date-this.elapsedTime;A.register(this)},toString:function(){return"Animation {duration millis: "+this.duration+", position:"+this.position+"}"},stop:function(H){clearTimeout(this.startAfterTimer);delete this.startAfterTimer;this._end(H)},abort:function(H){A.unregister(this);this.onabort(H||{})},_end:function(H){this.playing=false;A.unregister(this);if(H!==false){this.onend()}}};var A=new function(){this.register=M;this.unregister=J;var O=17,N=[],P;function M(R){if(N.length===0){H.call(this)}for(var Q=0;Q<N.length;Q++){if(N[Q]===R){return}}N.push(R)}function J(R){for(var Q=0;Q<N.length;Q++){if(N[Q]===R){N.splice(Q,1)}}if(N.length===0){N=[];K.call(this)}}function H(){P=setInterval(I,O)}function I(){var R=0,S;for(;R<N.length;R++){try{S=N[R];L(S)}catch(Q){if(S){S.abort(Q)}}}}function K(){self.clearInterval(P)}function L(R){var Q=new Date-R._startTime;if(Q>=R.timeLimit){R.run(R.position=R.endOffset);R[B]=R.endValue;R._end();return}var S=Q/R.duration,T=R.transition;if(R.isReversed){R[B]=R.startValue-S;if(R._transitionBackwards){R.position=1-T(1-R[B])}else{R.position=T(R[B])}}else{R[B]=R.startValue+S;R.position=T(R[B])}if(typeof R.onplay=="function"){R.onplay(R.position)}R.run(R.position)}};var F=Math.PI,G=Math.atan,D=Math.cos;APE.anim.Transitions={none:C,accel:function(H){return H*H*H},decel:function(H){H=1-H;return 1-(H*H*H)},reverse:function(H){return 1-H},getSigmoid:function(I){I=I||1;return H;function H(J){return(G(I*(2*J-1))/G(I)+1)/(2)}},easeInEaseOut:function(H){return(G(H*F/1-F/2)+1)/2.0038848218538874},wobble:function(H){return(-D(3*H*F)/2)+0.5},loop:function(H){return(-D(2*H*F)/2)+0.5},spring:function(H){return 1-(D(H*4.5*F)*Math.exp(-H*6))},swingTo:function(I){var H=1.70158;return(I-=1)*I*((H+1)*I+H)+1},swingToFrom:function(I){var H=1.70158;if((I/=0.5)<1){return 0.5*(I*I*(((H*=(1.525))+1)*I-H))}return 0.5*((I-=2)*I*(((H*=(1.525))+1)*I+H)+2)}}})();(function(){var Y=window.APE,X=Y.anim,g=X.Animation,W=g.prototype,e=Y.dom,T,I="fromValue",c="opacity",O="toValue",N="px",J="prototype",A="blendTo",b="toString",f="createSubclass",M="style";X.StyleTransition=L;function L(k,h,i,j){g.call(this,i);if(k.id){k=k.id}this.id=k;if(j){this.transition=j}this.init(h)}Y[f](L,g,{_start:function(){this[M]=document.getElementById(this.id)[M];W._start.call(this)},_end:function(){this[M]=null;W._end.call(this)},run:function(n){var k=0,m=this.adapters,h=m.length,l=this[M],j;while(k<h){j=m[k++];l[j.prop]=j[A](n)}},init:function(n){var j=document.getElementById(this.id),p=[],o,h,m,i=j[M],k=i.cssText,l={};if(T===undefined){T=!(c in i)&&("filter" in i)}for(h in n){if(!n[h]){continue}if(h===c&&T&&!j.currentStyle.hasLayout){i.zoom="1"}l[h]=e.getStyle(j,h)}d(j,n);for(h in n){m=n[h];if(D.test(m)){m=e.getStyle(j,h)}o=S.fromValues(h,l[h],m);p.push(o)}i.cssText=k;p.sort(function(r,q){return(r instanceof B)?-1:1});this.adapters=p},toString:function(){return"StyleTransitionAdapter : id=#"+this.id+"\n"+W[b].call(this)+"\nAdapters:\n "+this.adapters.join("\n ")}});function d(k,i){var l,h,j=k[M];for(l in i){h=i[l];if(l===c){e.setOpacity(k,h)}else{j[l]=h}}j.visibility="visible";j.display="block"}var D=/(^-?\d+|(?:-?\d*\.\d+))(px|em|ex|pt|pc|in|cm|mm|%)/i,E=/color/i,K=/(?:width|height|padding|fontSize)$/ig,V=/^\d+$/,C=/^(?:hidden|collapse)/;var S={fromValues:function(k,j,i){var h;if(K.test(k)){h=H}else{if(E.test(k)){h=a}else{if(D.test(j)){h=Z}else{if(k===c){h=T?F:G}else{if(k=="fontWeight"&&V.test(j)&&V.test(i)){h=P}else{if(k==="visibility"&&C.test(j)||k=="display"&&j=="none"){h=B}else{h=R}}}}}}return new h(k,j,i)}};var U=Y.color&&Y.color.ColorRGB;function Q(j,i,h){this.prop=j;this[I]=i;this[O]=h}Q[J][b]=function(){return"Transition: "+this.prop+", "+this[I][b]()+" \u2014 "+this[O][b]()};function a(l,k,h){if(!U){U=Y.color.ColorRGB}var j=U.fromString(k),i=U.fromString(h);Q.call(this,l,j,i);this.currentValue=new U()}Y[f](a,Q);a[J][A]=function(h){var i=U.blend(this[I],this[O],h,this.currentValue);return i[b]()};function Z(j,i,h){Q.call(this,j,parseFloat(i),parseFloat(h))}Y[f](Z,Q);Z[J][A]=function(i){var h=1-i;return((this[I]*h)+(this[O]*i))+N};function H(){Z.apply(this,arguments)}Y[f](H,Z);H[J][A]=function(j){var h=1-j,i=Math.max((this[I]*h)+(this[O]*j),0)+N;return i};function G(j,i,h){Q.call(this,j,parseFloat(i),parseFloat(h))}Y[f](G,Q);G[J][A]=function(j){var h=1-j,i=Math.max((this[I]*h)+(this[O]*j),0);return i};function F(j,i,h){Q.call(this,"filter",i,h)}Y[f](F,Q);F[J][A]=function(j){var h=1-j,i=Math.abs((this[I]*h)+(this[O]*j),0);return"alpha(opacity="+Math.abs(i*100)+")"};function P(j,i,h){Q.call(this,j,parseInt(i,10),parseInt(h,10))}Y[f](P,Q);P[J][A]=function(j){var h=1-j,i=(((this[I]*h)+(this[O]*j))/100<<0)*100;if(i<100){return 100}if(i>900){return 900}return i};function R(j,i,h){Q.call(this,j,i,h)}Y[f](R,Q);R[J][A]=function(h){if(h===1){return this[O]}return this[I]};function B(j,i,h){Q.call(this,j,i,h)}Y[f](B,Q);B[J][A]=function(h){if(h===0){return this[I]}return this[O]}})();
+APE.namespace("APE.anim");(function(){APE.anim.Animation=E;var B="rationalValue";function E(H){if(typeof H=="number"){this.duration=H*1000}this.timeLimit=this.duration}function C(H){return H}E.prototype={paused:false,duration:1000,timeLimit:1000,isReversed:false,startOffset:0,endOffset:1,startValue:0,endValue:1,rationalValue:0,transition:C,position:0,onstart:C,onend:C,onabort:function(H){throw H},run:C,start:function(){if(this.paused){return}this.timeLimit=this.duration;this.endOffset=this.transition(this.endValue);this._start()},startAfter:function(H){var J=this;function I(){J.start();clearTimeout(this.startAfterTimer);delete J.startAfterTimer}J.startAfterTimer=setTimeout(I,H)},_start:function(){A.unregister(this);this._startTime=+new Date;this.onstart();A.register(this);this.started=true;this.playing=true;clearTimeout(this.startAfterTimer);delete this.startAfterTimer},seekTo:function(J,H){J=parseFloat(J);if(!isFinite(J)){return}if(J===this[B]){return}this.startOffset=this.position;this.startValue=this[B];this.endValue=J;var I=Math.abs(J-this.startValue);this.timeLimit=this.duration*I;this.isReversed=(J<this[B]);this._transitionBackwards=this.isReversed&&H;if(this._transitionBackwards){this.endOffset=1-this.transition(1-J)}else{this.endOffset=this.transition(J)}this._start()},toggleDirection:function(){if(!this.started){this.start();return}if(this.isReversed){this.seekTo(1)}else{this.seekTo(0,this.position==1)}},reset:function(){this.position=0;this.timeLimit=this.duration;this.started=false},pause:function(){if(this.paused||!this.playing){return}this.paused=true;this.elapsedTime=new Date-this._startTime;A.unregister(this)},resume:function(){if(!this.paused){return}this.paused=false;this._startTime=new Date-this.elapsedTime;A.register(this)},toString:function(){return"Animation {duration millis: "+this.duration+", position:"+this.position+"}"},stop:function(){clearTimeout(this.startAfterTimer);delete this.startAfterTimer;this._end()},abort:function(H){A.unregister(this);this.onabort(H||{})},_end:function(){this.playing=false;A.unregister(this);if(this.started){this.onend()}}};var A=new function(){this.register=M;this.unregister=J;var O=17,N=[],P;function M(R){if(N.length===0){H.call(this)}for(var Q=0;Q<N.length;Q++){if(N[Q]===R){return}}N.push(R)}function J(R){for(var Q=0;Q<N.length;Q++){if(N[Q]===R){N.splice(Q,1)}}if(N.length===0){N=[];K.call(this)}}function H(){P=setInterval(I,O)}function I(){var R=0,S;for(;R<N.length;R++){try{S=N[R];L(S)}catch(Q){if(S){S.abort(Q)}}}}function K(){self.clearInterval(P)}function L(R){var Q=new Date-R._startTime;if(Q>=R.timeLimit){R.run(R.position=R.endOffset);R[B]=R.endValue;R._end();return}var S=Q/R.duration,T=R.transition;if(R.isReversed){R[B]=R.startValue-S;if(R._transitionBackwards){R.position=1-T(1-R[B])}else{R.position=T(R[B])}}else{R[B]=R.startValue+S;R.position=T(R[B])}if(typeof R.onplay=="function"){R.onplay(R.position)}R.run(R.position)}};var F=Math.PI,G=Math.atan,D=Math.cos;APE.anim.Transitions={none:C,accel:function(H){return H*H*H},decel:function(H){H=1-H;return 1-(H*H*H)},reverse:function(H){return 1-H},getSigmoid:function(I){I=I||1;return H;function H(J){return(G(I*(2*J-1))/G(I)+1)/(2)}},easeInEaseOut:function(H){return(G(H*F/1-F/2)+1)/2.0038848218538874},wobble:function(H){return(-D(3*H*F)/2)+0.5},loop:function(H){return(-D(2*H*F)/2)+0.5},spring:function(H){return 1-(D(H*4.5*F)*Math.exp(-H*6))},swingTo:function(I){var H=1.70158;return(I-=1)*I*((H+1)*I+H)+1},swingToFrom:function(I){var H=1.70158;if((I/=0.5)<1){return 0.5*(I*I*(((H*=(1.525))+1)*I-H))}return 0.5*((I-=2)*I*(((H*=(1.525))+1)*I+H)+2)}}})();(function(){var Y=window.APE,X=Y.anim,g=X.Animation,W=g.prototype,e=Y.dom,T,I="fromValue",c="opacity",O="toValue",N="px",J="prototype",A="blendTo",b="toString",f="createSubclass",M="style";X.StyleTransition=L;function L(k,h,i,j){g.call(this,i);if(k.id){k=k.id}this.id=k;if(j){this.transition=j}this.init(h)}Y[f](L,g,{_start:function(){this[M]=document.getElementById(this.id)[M];W._start.call(this)},_end:function(){this[M]=null;W._end.call(this)},run:function(n){var k=0,m=this.adapters,h=m.length,l=this[M],j;while(k<h){j=m[k++];l[j.prop]=j[A](n)}},init:function(n){var j=document.getElementById(this.id),p=[],o,h,m,i=j[M],k=i.cssText,l={};if(T===undefined){T=!(c in i)&&("filter" in i)}for(h in n){if(!n[h]){continue}if(h===c&&T&&!j.currentStyle.hasLayout){i.zoom="1"}l[h]=e.getStyle(j,h)}d(j,n);for(h in n){m=n[h];if(D.test(m)){m=e.getStyle(j,h)}o=S.fromValues(h,l[h],m);p.push(o)}i.cssText=k;p.sort(function(r,q){return(r instanceof B)?-1:1});this.adapters=p},toString:function(){return"StyleTransitionAdapter : id=#"+this.id+"\n"+W[b].call(this)+"\nAdapters:\n "+this.adapters.join("\n ")}});function d(k,i){var l,h,j=k[M];for(l in i){h=i[l];if(l===c){e.setOpacity(k,h)}else{j[l]=h}}j.visibility="visible";j.display="block"}var D=/(^-?\d+|(?:-?\d*\.\d+))(px|em|ex|pt|pc|in|cm|mm|%)/i,E=/color/i,K=/(?:width|height|padding|fontSize)$/ig,V=/^\d+$/,C=/^(?:hidden|collapse)/;var S={fromValues:function(k,j,i){var h;if(K.test(k)){h=H}else{if(E.test(k)){h=a}else{if(D.test(j)){h=Z}else{if(k===c){h=T?F:G}else{if(k=="fontWeight"&&V.test(j)&&V.test(i)){h=P}else{if(k==="visibility"&&C.test(j)||k=="display"&&j=="none"){h=B}else{h=R}}}}}}return new h(k,j,i)}};var U=Y.color&&Y.color.ColorRGB;function Q(j,i,h){this.prop=j;this[I]=i;this[O]=h}Q[J][b]=function(){return"Transition: "+this.prop+", "+this[I][b]()+" \u2014 "+this[O][b]()};function a(l,k,h){if(!U){U=Y.color.ColorRGB}var j=U.fromString(k),i=U.fromString(h);Q.call(this,l,j,i);this.currentValue=new U()}Y[f](a,Q);a[J][A]=function(h){var i=U.blend(this[I],this[O],h,this.currentValue);return i[b]()};function Z(j,i,h){Q.call(this,j,parseFloat(i),parseFloat(h))}Y[f](Z,Q);Z[J][A]=function(i){var h=1-i;return((this[I]*h)+(this[O]*i))+N};function H(){Z.apply(this,arguments)}Y[f](H,Z);H[J][A]=function(j){var h=1-j,i=Math.max((this[I]*h)+(this[O]*j),0)+N;return i};function G(j,i,h){Q.call(this,j,parseFloat(i),parseFloat(h))}Y[f](G,Q);G[J][A]=function(j){var h=1-j,i=Math.max((this[I]*h)+(this[O]*j),0);return i};function F(j,i,h){Q.call(this,"filter",i,h)}Y[f](F,Q);F[J][A]=function(j){var h=1-j,i=Math.abs((this[I]*h)+(this[O]*j),0);return"alpha(opacity="+Math.abs(i*100)+")"};function P(j,i,h){Q.call(this,j,parseInt(i,10),parseInt(h,10))}Y[f](P,Q);P[J][A]=function(j){var h=1-j,i=(((this[I]*h)+(this[O]*j))/100<<0)*100;if(i<100){return 100}if(i>900){return 900}return i};function R(j,i,h){Q.call(this,j,i,h)}Y[f](R,Q);R[J][A]=function(h){if(h===1){return this[O]}return this[I]};function B(j,i,h){Q.call(this,j,i,h)}Y[f](B,Q);B[J][A]=function(h){if(h===0){return this[I]}return this[O]}})();
View
16 build/anim/anim.js
@@ -234,11 +234,12 @@ APE.namespace("APE.anim");
},
/**
- * resets the animation to position 0.
+ * s the animation to position 0.
*/
reset : function() {
this.position = 0;
this.timeLimit = this.duration;
+ this.started = false;
},
/**
@@ -270,15 +271,11 @@ APE.namespace("APE.anim");
/**
* Ends the anim.
- *
- * @param {boolean} ended, if true, calls onend().
- * This is not a pause() method; calling stop()
- * then resume() will not cause the Animation to restart.
*/
- stop : function(ended) {
+ stop : function() {
clearTimeout(this.startAfterTimer);
delete this.startAfterTimer;
- this._end(ended);
+ this._end();
},
/** Cancels the anim where it is; does not call onend() */
@@ -287,11 +284,10 @@ APE.namespace("APE.anim");
this.onabort(ex || {});
},
- /** @protected - can use in subclass. */
- _end : function(complete) {
+ _end : function() {
this.playing = false;
Manager.unregister(this);
- if (complete !== false) {
+ if (this.started) {
this.onend();
}
}
View
16 src/anim/Animation.js
@@ -234,11 +234,12 @@ APE.namespace("APE.anim");
},
/**
- * resets the animation to position 0.
+ * s the animation to position 0.
*/
reset : function() {
this.position = 0;
this.timeLimit = this.duration;
+ this.started = false;
},
/**
@@ -270,15 +271,11 @@ APE.namespace("APE.anim");
/**
* Ends the anim.
- *
- * @param {boolean} ended, if true, calls onend().
- * This is not a pause() method; calling stop()
- * then resume() will not cause the Animation to restart.
*/
- stop : function(ended) {
+ stop : function() {
clearTimeout(this.startAfterTimer);
delete this.startAfterTimer;
- this._end(ended);
+ this._end();
},
/** Cancels the anim where it is; does not call onend() */
@@ -287,11 +284,10 @@ APE.namespace("APE.anim");
this.onabort(ex || {});
},
- /** @protected - can use in subclass. */
- _end : function(complete) {
+ _end : function() {
this.playing = false;
Manager.unregister(this);
- if (complete !== false) {
+ if (this.started) {
this.onend();
}
}
View
BIN test/tests/.DS_Store
Binary file not shown.
View
14 test/tests/anim/Animation-test.html
@@ -195,7 +195,7 @@
// We need to make sure onend fires each time an
// animation ends.
testToggleDirection : function() {
- var a = new Animation();
+ var a = new Animation(.1);
var numFrames = 0;
var endcount = 0;
a.onplay = function(pos) {
@@ -210,7 +210,7 @@
YAHOO.log("numframes: " + numFrames, "info", "TestRunner");
Assert.areEqual(2, endcount, "onend() should have fired twice.");
Assert.areEqual(0, a.position, "Wasn't reversed back to 0");
- }, 2100);
+ }, 400);
},
testStop : function() {
@@ -231,8 +231,16 @@
YAHOO.log("a.position: " + a.position, "info", "TestRunner");
}, 120);
}, 200);
- }
+ },
+ testReset : function() {
+ var a = new Animation();
+ a.onend = function() {
+ Assert.fail("onend fired.");
+ }
+ a.start();
+ a.reset();
+ }
});
var transitionTestCase = new YAHOO.tool.TestCase({

0 comments on commit 8578e74

Please sign in to comment.
Something went wrong with that request. Please try again.