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

@DavMila:

> E.g. perhaps we can think about an `animation-trigger-coordination` or an `animation-trigger-group` property which has a `name` and a `type`. The `type`s could have meanings corresponding to:
>
> * if ANY triggers in this group tripped, play the animation, or
> * iff ALL triggers in this group are currently tripped, play the animation,
other interesting ideas.

Yeah you beat me to it. I was also considering suggesting a sort of a "Trigger Group", kind of like AnimationGroup. Sort of an object that can take multiple triggers as input, and output as a single trigger. Then allow authors to specify how these triggers's state interact to calculate the output.

After reviewing more of @szager-chromium's PR for adding event-triggers I understand how multiple triggers per animation seem trivial from that point of view. Since `once` can work by simply not allowing animations to rewind, and the other behaviors mostly work because of the event-based stateless nature. However, there's still the bit of state there inside the trigger - the `idle` state of the trigger (I think it was confused with `idle` play-state of the animation). So this is still an issue.
But like you said, with the stateful nature timeline-based triggers this becomes messy.

> Script can enforce this by throwing an error when `AnimationTrigger.addAnimation` (or whatever we settle on in https://github.com/w3c/csswg-drafts/issues/12397) is called on a trigger which already has an animation attached.

We could also say that adding an animation to a trigger simply detaches it form its current trigger and attaches to the new one.

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


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

Received on Friday, 18 July 2025 14:10:05 UTC