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

Commit

Permalink
fix(ngAnimate): close parent animations only when there are classes t…
Browse files Browse the repository at this point in the history
…o resolve

Previously if a parent animation was cancelled then it would not resolve
the runner when that happens. This is now fixed in this patch. Another
fix in this patch ensures that a parent animation is only cancelled if
the animation contains any classes to resolve. This prevents inline
animations from being cancelled.
  • Loading branch information
matsko committed Apr 16, 2015
1 parent e41faaa commit 1459be1
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/ngAnimate/animateQueue.js
Expand Up @@ -388,6 +388,7 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
// it, otherwise if it's the same then the end result will be the same too
if (animationCancelled || (isStructural && animationDetails.event !== event)) {
options.domOperation();
runner.end();
}

return;
Expand Down Expand Up @@ -482,7 +483,7 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
// animations to properly function (otherwise any CSS selectors may not work)
function examineParentAnimation(node, animationDetails) {
// enter/leave/move always have priority
if (animationDetails.structural) return;
if (animationDetails.structural || !hasAnimationClasses(animationDetails.options)) return;

if (animationDetails.state === RUNNING_STATE) {
animationDetails.runner.end();
Expand Down
37 changes: 35 additions & 2 deletions test/ngAnimate/animateSpec.js
Expand Up @@ -510,16 +510,49 @@ describe("animations", function() {

describe('parent animations', function() {
it('should immediately end a pre-digest parent class-based animation if a structural child is active',
inject(function($rootScope, $animate) {
inject(function($rootScope, $animate, $$rAF) {

parent.append(element);
var child = jqLite('<div></div>');
$animate.addClass(parent, 'abc');

var itsOver = false;
$animate.addClass(parent, 'abc').done(function() {
itsOver = true;
});

$animate.enter(child, element);
$$rAF.flush();

expect(itsOver).toBe(false);
$rootScope.$digest();

expect(parent).toHaveClass('abc');
expect(itsOver).toBe(true);
}));

it('should not end a pre-digest parent animation if it does not have any classes to add/remove',
inject(function($rootScope, $animate, $$rAF) {

parent.append(element);
var child = jqLite('<div></div>');
var runner = $animate.animate(parent,
{ height:'0px' },
{ height:'100px' });

var doneCount = 0;
runner.done(function() {
doneCount++;
});

var runner2 = $animate.enter(child, element);
runner2.done(function() {
doneCount++;
});

$rootScope.$digest();
$$rAF.flush();

expect(doneCount).toBe(0);
}));

it('should immediately end a parent class-based animation if a structural child is active',
Expand Down

0 comments on commit 1459be1

Please sign in to comment.