[csswg-drafts] [web-animations-2][css-animations-2] Should an animation be allowed to have multiple triggers associated? (#12399)

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

== [web-animations-2][css-animations-2] Should an animation be allowed to have multiple triggers associated? ==
I followed up #12119 where we resolved to treat AnimationTriggers as external controllers of Animations by filing  #12397 where we should resolve on the explicit API by which Animations will be associated with triggers. One additional question that we should answer is what happens when that explicit API is used to associate an animation with multiple triggers., e.g.:

```
const anim = Animation();
const trigger1 = AnimationTrigger();
trigger1.addAnimation(anim);

const trigger2 = AnimationTrigger();
trigger2.addAnimation(anim);
```

In this example, when the animation is added to `trigger2` should its association with `trigger1` be terminated or left intact? (Is there another option?)

I propose that we leave the previous association intact, i.e. allow animations be associated with multiple triggers. This will enable use cases where an author wishes to orchestrate multiple sources which can trigger the playing of an animation whether they be scroll-based source or event/input-based sources.

Since it could happen that the associated triggers wish to perform conflicting operations, e.g. `play()` vs `pause()`, we should decide what the outcome should be in these scenarios. A simple proposal would be to let the outcome be the outcome of running each trigger's operation in the order in which the triggers were created. While it would be possible to construct cases where this doesn't play so well, I think it gives an author a simple conceptual model to work with. I would propose that we go with this simple model to start, and if we discover use cases that can't be done with this simple model, we can introduce ways of describing interactions between triggers on the same animation  similar to how `animation-composition` was introduced for `animation`.

FYI @szager-chromium @flackr @ydaniv @birtles 


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


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

Received on Wednesday, 25 June 2025 15:30:31 UTC