[csswg-drafts] [css-animations-2][css-transitions-2] Add animation object to animation/transition events. (#9010)

flackr has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-animations-2][css-transitions-2] Add animation object to animation/transition events. ==
Currently the [css-animations-1 AnimationEvent](https://www.w3.org/TR/css-animations-1/#interface-animationevent-idl) and the [css-transitions-1 TransitionEvent](https://www.w3.org/TR/css-transitions-1/#interface-transitionevent-idl) only provide details about the animation (its name, and timing) or transition (property and timing), but if you wanted to get the actual [Animation object](https://www.w3.org/TR/web-animations-1/#the-animation-interface) you would have to call getAnimations() on the element and find the corresponding animation. E.g.

```
element.addEventListener('animationstart', (evt) => {
  // evt does not contain the animation so we have to find it.
  let animation = element.getAnimations().find(anim => anim.animationName == evt.animationName);
});
```

If the same animation name is started twice, e.g. `animation: keyframes 1s, keyframes 1s`, the developer doesn't have any way to know which Animation object in the getAnimations list corresponds to the AnimationEvent.

I propose we add the web-animations Animation object for the animation / transition to these events so that developers can easily get the associated Animation from the events. I'd propose calling it `animation` in both interfaces though we could consider calling it `transition` in the TransitionEvent interface even though the type would be Animation.

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/9010 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Tuesday, 27 June 2023 14:10:10 UTC