[csswg-drafts] [web-animations-2] Should there be events on target elements to detect started web animations? (#9011)

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

== [web-animations-2] Should there be events on target elements to detect started web animations? ==
While there are bubbling events for started css animations (e.g. [animationstart](https://www.w3.org/TR/css-animations-1/#eventdef-globaleventhandlers-animationstart)) and css transitions (e.g. [transitionstart](https://www.w3.org/TR/css-transitions-1/#transitionstart)) there are no events to observe when web animations have been started. An author would have to track when they start web animations internally.

Should we have events for web-animations which fire at the effect target? If so, would they be the same names / set of events as the [css animation events](https://www.w3.org/TR/css-animations-1/#event-animationevent) (animationstart, animationend, animationiteration, animationcancel)?

If we do want to add these events, there are many complicated scenarios to work out, e.g. imagine the author wants to observe all animations:
```js
document.body.addEventListener('animationstart', (evt) => {
  console.log(evt);
});
```

Animations can be started before the target is attached.
```js
let elem = document.createElement('div');
elem.animate(keyframes, options); // animation started, but elem is not attached so the above listener wouldn't see it.
document.body.appendChild(elem);
```

The target can be changed after the animation is started
```js
let anim = new Animation(keyframes, options);
anim.play(); // animation started, but has no target to dispatch events to
anim.target = document.body;
```

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/9011 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:33:09 UTC