diff --git a/src/ngAnimate/animateCss.js b/src/ngAnimate/animateCss.js index b9757f27777c..54bc23c97922 100644 --- a/src/ngAnimate/animateCss.js +++ b/src/ngAnimate/animateCss.js @@ -756,6 +756,13 @@ var $AnimateCssProvider = ['$animateProvider', function($animateProvider) { element.off(events.join(' '), onAnimationProgress); } + //Cancel the fallback closing timeout and remove the timer data + var animationTimerData = element.data(ANIMATE_TIMER_KEY); + if (animationTimerData) { + $timeout.cancel(animationTimerData[0].timer); + element.removeData(ANIMATE_TIMER_KEY); + } + // if the preparation function fails then the promise is not setup if (runner) { runner.complete(!rejected); diff --git a/test/ngAnimate/.jshintrc b/test/ngAnimate/.jshintrc index fcaf04058079..d182bdf2d2d4 100644 --- a/test/ngAnimate/.jshintrc +++ b/test/ngAnimate/.jshintrc @@ -12,6 +12,7 @@ "TRANSITIONEND_EVENT": false, "TRANSITION_PROP": false, "ANIMATION_PROP": false, - "ANIMATIONEND_EVENT": false + "ANIMATIONEND_EVENT": false, + "ANIMATE_TIMER_KEY": false } } diff --git a/test/ngAnimate/animateCssSpec.js b/test/ngAnimate/animateCssSpec.js index 7de34ee58615..6e0b66073e76 100644 --- a/test/ngAnimate/animateCssSpec.js +++ b/test/ngAnimate/animateCssSpec.js @@ -1309,6 +1309,29 @@ describe("ngAnimate $animateCss", function() { expect(getPossiblyPrefixedStyleValue(element, 'transition-delay')).toBeOneOf('', '0s'); })); + + it("should cancel the timeout when the animation is ended normally", + inject(function($animateCss, $document, $rootElement, $timeout) { + + ss.addRule('.ng-enter', 'transition:10s linear all;'); + + var element = jqLite('
'); + $rootElement.append(element); + jqLite($document[0].body).append($rootElement); + + var animator = $animateCss(element, { event: 'enter', structural: true }); + animator.start(); + triggerAnimationStartFrame(); + + expect(element).toHaveClass('ng-enter'); + expect(element).toHaveClass('ng-enter-active'); + + animator.end(); + + expect(element.data(ANIMATE_TIMER_KEY)).toBeUndefined(); + expect(function() {$timeout.verifyNoPendingTasks();}).not.toThrow(); + })); + }); describe("getComputedStyle", function() {