Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

fix($animate): cancel fallback timeout when animation ends normally #13787

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/ngAnimate/animateCss.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion test/ngAnimate/.jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"TRANSITIONEND_EVENT": false,
"TRANSITION_PROP": false,
"ANIMATION_PROP": false,
"ANIMATIONEND_EVENT": false
"ANIMATIONEND_EVENT": false,
"ANIMATE_TIMER_KEY": false
}
}
23 changes: 23 additions & 0 deletions test/ngAnimate/animateCssSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('<div></div>');
$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() {
Expand Down