Skip to content

Commit c341c22

Browse files
Merge pull request #6 from angular/master
Update upstream
2 parents bc6a4fe + 20590c0 commit c341c22

File tree

3 files changed

+64
-4
lines changed

3 files changed

+64
-4
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();

src/ngMock/browserTrigger.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -55,25 +55,25 @@
5555
if (/transitionend/.test(eventType)) {
5656
if (window.WebKitTransitionEvent) {
5757
evnt = new window.WebKitTransitionEvent(eventType, eventData);
58-
evnt.initEvent(eventType, false, true);
58+
evnt.initEvent(eventType, eventData.bubbles, true);
5959
} else {
6060
try {
6161
evnt = new window.TransitionEvent(eventType, eventData);
6262
} catch (e) {
6363
evnt = window.document.createEvent('TransitionEvent');
64-
evnt.initTransitionEvent(eventType, null, null, null, eventData.elapsedTime || 0);
64+
evnt.initTransitionEvent(eventType, eventData.bubbles, null, null, eventData.elapsedTime || 0);
6565
}
6666
}
6767
} else if (/animationend/.test(eventType)) {
6868
if (window.WebKitAnimationEvent) {
6969
evnt = new window.WebKitAnimationEvent(eventType, eventData);
70-
evnt.initEvent(eventType, false, true);
70+
evnt.initEvent(eventType, eventData.bubbles, true);
7171
} else {
7272
try {
7373
evnt = new window.AnimationEvent(eventType, eventData);
7474
} catch (e) {
7575
evnt = window.document.createEvent('AnimationEvent');
76-
evnt.initAnimationEvent(eventType, null, null, null, eventData.elapsedTime || 0);
76+
evnt.initAnimationEvent(eventType, eventData.bubbles, null, null, eventData.elapsedTime || 0);
7777
}
7878
}
7979
} else if (/touch/.test(eventType) && supportsTouchEvents()) {

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)