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

Commit 20590c0

Browse files
committed
fix(ngAnimate): don't close animations when child transitions close
1 parent 2f7fad5 commit 20590c0

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

src/ngAnimate/animateCss.js

+6
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,12 @@ var $AnimateCssProvider = ['$animateProvider', /** @this */ function($animatePro
805805
event.stopPropagation();
806806
var ev = event.originalEvent || event;
807807

808+
if (ev.target !== node) {
809+
// Since TransitionEvent / AnimationEvent bubble up,
810+
// we have to ignore events by finished child animations
811+
return;
812+
}
813+
808814
// we now always use `Date.now()` due to the recent changes with
809815
// event.timeStamp in Firefox, Webkit and Chrome (see #13494 for more info)
810816
var timeStamp = ev.$manualTimeStamp || Date.now();

test/ngAnimate/animateCssSpec.js

+54
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,60 @@ describe('ngAnimate $animateCss', function() {
532532
assertAnimationComplete(true);
533533
}));
534534

535+
it('should not close a transition when a child element fires the transitionend event',
536+
inject(function($animateCss) {
537+
538+
ss.addPossiblyPrefixedRule('.ng-enter', 'transition:4s linear all;');
539+
ss.addPossiblyPrefixedRule('.non-angular-animation', 'transition:5s linear all;');
540+
541+
var child = angular.element('<div class="non-angular-animation"></div>');
542+
element.append(child);
543+
544+
var animator = $animateCss(element, options);
545+
animator.start();
546+
triggerAnimationStartFrame();
547+
548+
browserTrigger(child, 'transitionend', {
549+
timeStamp: Date.now(),
550+
elapsedTime: 5,
551+
bubbles: true
552+
});
553+
554+
transitionProgress(element, 1);
555+
556+
assertAnimationComplete(false);
557+
558+
transitionProgress(element, 4);
559+
assertAnimationComplete(true);
560+
}));
561+
562+
it('should not close a keyframe animation when a child element fires the animationend event',
563+
inject(function($animateCss) {
564+
565+
ss.addPossiblyPrefixedRule('.ng-enter', 'animation:animation 4s;');
566+
ss.addPossiblyPrefixedRule('.non-angular-animation', 'animation:animation 5s;');
567+
568+
var child = angular.element('<div class="non-angular-animation"></div>');
569+
element.append(child);
570+
571+
var animator = $animateCss(element, options);
572+
animator.start();
573+
triggerAnimationStartFrame();
574+
575+
browserTrigger(child, 'animationend', {
576+
timeStamp: Date.now(),
577+
elapsedTime: 5,
578+
bubbles: true
579+
});
580+
581+
keyframeProgress(element, 1);
582+
583+
assertAnimationComplete(false);
584+
585+
keyframeProgress(element, 4);
586+
assertAnimationComplete(true);
587+
}));
588+
535589
it('should use the highest keyframe duration value detected in the CSS class', inject(function($animateCss) {
536590
ss.addPossiblyPrefixedRule('.ng-enter', 'animation:animation 1s, animation 2s, animation 3s;');
537591

0 commit comments

Comments
 (0)