Skip to content

Commit edb06d4

Browse files
Adam RaineDevtools-frontend LUCI CQ
authored andcommitted
[ui-utils] Stop CSS animation on cancel
If the animation is started and then the element is hidden, the animation will restart once the element is visible again. IMO the animation should never restart for `runCSSAnimationOnce`. Bug: None Change-Id: I80f119fdc7cef414989fad363ed8d31428de76af Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/5952312 Commit-Queue: Alina Varkki <[email protected]> Reviewed-by: Alina Varkki <[email protected]> Auto-Submit: Adam Raine <[email protected]>
1 parent 39cc1b6 commit edb06d4

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

front_end/ui/legacy/UIUtils.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,13 +690,15 @@ export function runCSSAnimationOnce(element: Element, className: string): void {
690690
function animationEndCallback(): void {
691691
element.classList.remove(className);
692692
element.removeEventListener('webkitAnimationEnd', animationEndCallback, false);
693+
element.removeEventListener('animationcancel', animationEndCallback, false);
693694
}
694695

695696
if (element.classList.contains(className)) {
696697
element.classList.remove(className);
697698
}
698699

699700
element.addEventListener('webkitAnimationEnd', animationEndCallback, false);
701+
element.addEventListener('animationcancel', animationEndCallback, false);
700702
element.classList.add(className);
701703
}
702704

0 commit comments

Comments
 (0)