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

Thanks, @DavMila.
We need to try and consider different use-cases here.

Let's start with considering examples with multiple timeline-based triggers:

- 2 `view()` triggers on same animation, one on the `x` axis and the second on the `y` axis. Should each apply its effect separately? What if the author wants a behavior where only if scrolled into a specific rect, the intersect of these two triggers' ranges, then they apply their effect?
- The above example becomes more concrete when used with 2 `pointer()` timelines, if an author would attempt to apply the triggers' effect only when the pointer is over the intersection of x and y.
- 2 overlapping `view()` or `pointer()` triggers on same animation with `once`, `state`, or `alternate` types.  Does entering one range apply the effect? And when entering the overlap area, do we re-apply the effect?

If we consider event-based triggers, though they aren't fully specified yet we can think of use-cases like:

- 2 `click` triggers of type `once` on different elements working on same animation. If the trigger contains the state, does each apply a `once` effect? Otherwise, if we expect for this animation to play once, this state should be part of the animation. Since the notion of "once" is part of the trigger, not the animation, this starts complicating the model.
- Same example above with `state` or `alternate`. 

I think if we just think in simple terms of "click" then this seems trivial. But honestly I think this just becomes a mess.
On top of that, we also don't have a way of specifying multiple triggers per animation in CSS. So I also don't think we should allow such a radically different API in Web Animations from CSS.

I propose we stick to a single trigger per animation, and keep ability for multiple animations per trigger.

-- 
GitHub Notification of comment by ydaniv
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/12399#issuecomment-3015122028 using your GitHub account


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

Received on Saturday, 28 June 2025 08:50:28 UTC