Skip to content

Commit bb85e90

Browse files
Ullfiszewa666
authored andcommitted
fix(events): start and end events capture bubbles
event-listeners should only act on start/end animation events from target element.
1 parent 163f430 commit bb85e90

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/animator.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,9 @@ export class CssAnimator {
258258
let animStart;
259259
let animHasStarted = false;
260260
this._addMultipleEventListener(element, 'webkitAnimationStart animationstart', animStart = (evAnimStart) => {
261+
if (evAnimStart.target !== element) {
262+
return;
263+
}
261264
animHasStarted = true;
262265
this.isAnimating = true;
263266

@@ -275,6 +278,9 @@ export class CssAnimator {
275278
if (!animHasStarted) {
276279
return;
277280
}
281+
if (evAnimEnd.target !== element) {
282+
return;
283+
}
278284

279285
// Step 3.1.0: Stop event propagation, bubbling will otherwise prevent parent animation
280286
evAnimEnd.stopPropagation();
@@ -388,6 +394,9 @@ export class CssAnimator {
388394
let animStart;
389395
let animHasStarted = false;
390396
this._addMultipleEventListener(element, 'webkitAnimationStart animationstart', animStart = (evAnimStart) => {
397+
if (evAnimStart.target !== element) {
398+
return;
399+
}
391400
animHasStarted = true;
392401
this.isAnimating = true;
393402

@@ -407,6 +416,9 @@ export class CssAnimator {
407416
if (! animHasStarted) {
408417
return;
409418
}
419+
if (evAnimEnd.target !== element) {
420+
return;
421+
}
410422

411423
// Step 3.1.0: Stop event propagation, bubbling will otherwise prevent parent animation
412424
evAnimEnd.stopPropagation();
@@ -467,6 +479,9 @@ export class CssAnimator {
467479
let animStart;
468480
let animHasStarted = false;
469481
this._addMultipleEventListener(element, 'webkitAnimationStart animationstart', animStart = (evAnimStart) => {
482+
if (evAnimStart.target !== element) {
483+
return;
484+
}
470485
animHasStarted = true;
471486
this.isAnimating = true;
472487

@@ -486,7 +501,10 @@ export class CssAnimator {
486501
if (! animHasStarted) {
487502
return;
488503
}
489-
504+
if (evAnimEnd.target !== element) {
505+
return;
506+
}
507+
490508
// Step 2.1.0: Stop event propagation, bubbling will otherwise prevent parent animation
491509
evAnimEnd.stopPropagation();
492510

0 commit comments

Comments
 (0)