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

Commit 1459be1

Browse files
committed
fix(ngAnimate): close parent animations only when there are classes to 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.
1 parent e41faaa commit 1459be1

File tree

2 files changed

+37
-3
lines changed

2 files changed

+37
-3
lines changed

src/ngAnimate/animateQueue.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
388388
// it, otherwise if it's the same then the end result will be the same too
389389
if (animationCancelled || (isStructural && animationDetails.event !== event)) {
390390
options.domOperation();
391+
runner.end();
391392
}
392393

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

487488
if (animationDetails.state === RUNNING_STATE) {
488489
animationDetails.runner.end();

test/ngAnimate/animateSpec.js

+35-2
Original file line numberDiff line numberDiff line change
@@ -510,16 +510,49 @@ describe("animations", function() {
510510

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

515515
parent.append(element);
516516
var child = jqLite('<div></div>');
517-
$animate.addClass(parent, 'abc');
517+
518+
var itsOver = false;
519+
$animate.addClass(parent, 'abc').done(function() {
520+
itsOver = true;
521+
});
518522

519523
$animate.enter(child, element);
524+
$$rAF.flush();
525+
526+
expect(itsOver).toBe(false);
520527
$rootScope.$digest();
521528

522529
expect(parent).toHaveClass('abc');
530+
expect(itsOver).toBe(true);
531+
}));
532+
533+
it('should not end a pre-digest parent animation if it does not have any classes to add/remove',
534+
inject(function($rootScope, $animate, $$rAF) {
535+
536+
parent.append(element);
537+
var child = jqLite('<div></div>');
538+
var runner = $animate.animate(parent,
539+
{ height:'0px' },
540+
{ height:'100px' });
541+
542+
var doneCount = 0;
543+
runner.done(function() {
544+
doneCount++;
545+
});
546+
547+
var runner2 = $animate.enter(child, element);
548+
runner2.done(function() {
549+
doneCount++;
550+
});
551+
552+
$rootScope.$digest();
553+
$$rAF.flush();
554+
555+
expect(doneCount).toBe(0);
523556
}));
524557

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

0 commit comments

Comments
 (0)