aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatias Niemelä2013-05-13 15:08:59 -0400
committerMisko Hevery2013-05-13 21:09:43 -0700
commit4acc28a310d006c62afe0de8ec82fed21c98c2d6 (patch)
treed0af37f0bd7c5b699b2a6d23505bb1700fcd352c /src
parentc8197b44eb0b4d49acda142f4179876732e1c751 (diff)
downloadangular.js-4acc28a310d006c62afe0de8ec82fed21c98c2d6.tar.bz2
feat(ngAnimate): cancel previous incomplete animations when new animations take place
Diffstat (limited to 'src')
-rw-r--r--src/ng/animator.js20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/ng/animator.js b/src/ng/animator.js
index 1f589e91..7fc35f3c 100644
--- a/src/ng/animator.js
+++ b/src/ng/animator.js
@@ -264,6 +264,7 @@ var $AnimatorProvider = function() {
var animationPolyfill = $animation(className);
var polyfillSetup = animationPolyfill && animationPolyfill.setup;
var polyfillStart = animationPolyfill && animationPolyfill.start;
+ var polyfillCancel = animationPolyfill && animationPolyfill.cancel;
if (!className) {
beforeFn(element, parent, after);
@@ -281,7 +282,13 @@ var $AnimatorProvider = function() {
return;
}
- element.data(NG_ANIMATE_CONTROLLER, {running:true});
+ var animationData = element.data(NG_ANIMATE_CONTROLLER) || {};
+ if(animationData.running) {
+ (polyfillCancel || noop)(element);
+ animationData.done();
+ }
+
+ element.data(NG_ANIMATE_CONTROLLER, {running:true, done:done});
element.addClass(className);
beforeFn(element, parent, after);
if (element.length == 0) return done();
@@ -354,10 +361,13 @@ var $AnimatorProvider = function() {
}
function done() {
- afterFn(element, parent, after);
- element.removeClass(className);
- element.removeClass(activeClassName);
- element.removeData(NG_ANIMATE_CONTROLLER);
+ if(!done.run) {
+ done.run = true;
+ afterFn(element, parent, after);
+ element.removeClass(className);
+ element.removeClass(activeClassName);
+ element.removeData(NG_ANIMATE_CONTROLLER);
+ }
}
};
}