Skip to content

Commit

Permalink
fix($animate): ensure class-based animations are always skipped befor…
Browse files Browse the repository at this point in the history
…e structural digests are run

Closes angular#5582
  • Loading branch information
matsko committed Jan 2, 2014
1 parent 50bf029 commit 9e6c753
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/ngAnimate/animate.js
Original file line number Diff line number Diff line change
Expand Up @@ -610,9 +610,14 @@ angular.module('ngAnimate', ['ng'])
}

var animations = [];

//only add animations if the currently running animation is not structural
//or if there is no animation running at all
if(!ngAnimateState.running || !(isClassBased && ngAnimateState.structural)) {
var allowAnimations = isClassBased ?
!ngAnimateState.disabled && (!ngAnimateState.running || !ngAnimateState.structural) :
true;

if(allowAnimations) {
forEach(matches, function(animation) {
//add the animation to the queue to if it is allowed to be cancelled
if(!animation.allowCancel || animation.allowCancel(element, animationEvent, className)) {
Expand Down
21 changes: 21 additions & 0 deletions test/ngAnimate/animateSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,27 @@ describe("ngAnimate", function() {
expect(completed).toBe(true);
}));

it("should skip class-based animations if animations are directly disabled on the same element", function() {
var capture;
module(function($animateProvider) {
$animateProvider.register('.capture', function() {
return {
addClass : function(element, className, done) {
capture = true;
done();
}
};
});
});
inject(function($animate, $rootScope, $sniffer, $timeout) {
$animate.enabled(true);
$animate.enabled(false, element);

$animate.addClass(element, 'capture');
expect(element.hasClass('capture')).toBe(true);
expect(capture).not.toBe(true);
});
});

it("should fire the cancel/end function with the correct flag in the parameters",
inject(function($animate, $rootScope, $sniffer, $timeout) {
Expand Down

0 comments on commit 9e6c753

Please sign in to comment.