Skip to content

refactor(core): distinguish animations that share a name - #70110

Open
SkyZeroZx wants to merge 1 commit into
angular:mainfrom
SkyZeroZx:refactor/improve-animation
Open

refactor(core): distinguish animations that share a name#70110
SkyZeroZx wants to merge 1 commit into
angular:mainfrom
SkyZeroZx:refactor/improve-animation

Conversation

@SkyZeroZx

Copy link
Copy Markdown
Contributor

animate.leave waits for the longest-running animation before removing an element. When multiple animations use the same keyframe name, their animationend events have the same animationName, so a shorter animation can be mistaken for the longest one and remove the element too early.

Track the Animation returned by getAnimations() and compare it with event.animation when available. Keep the existing name/property checks as a fallback for older browsers and computed-style detection.

Add an acceptance test where the shorter same-name animation ends first and verify the element stays until the longest animation finishes.

event.animation is supported in Firefox 152+, Chrome 151+, and Safari 27 (currently beta).

References:
CSS Animations 2: https://drafts.csswg.org/css-animations-2/#dom-animationevent-animation
CSS Transitions 2: https://drafts.csswg.org/css-transitions-2/#dom-transitionevent-animation
Chrome 151: https://developer.chrome.com/release-notes/151#animation_accessor_on_animation_and_transition_events

Before

See demo : https://stackblitz.com/edit/stackblitz-starters-kafwrtts?file=src%2Fmain.ts

before.mp4

After

after.mp4

@pullapprove
pullapprove Bot requested a review from kirjs August 6, 2026 23:27
@angular-robot angular-robot Bot added the area: core Issues related to the framework runtime label Aug 6, 2026
@ngbot ngbot Bot added this to the Backlog milestone Aug 6, 2026
animate.leave waits for the longest-running animation before removing an element. When multiple animations use the same keyframe name, their animationend events have the same animationName, so a shorter animation can be mistaken for the longest one and remove the element too early.

Track the Animation returned by getAnimations() and compare it with event.animation when available. Keep the existing name/property checks as a fallback for older browsers and computed-style detection.
@SkyZeroZx
SkyZeroZx force-pushed the refactor/improve-animation branch from 0b817a7 to 33eca1f Compare August 6, 2026 23:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: core Issues related to the framework runtime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant