Re: [csswg-drafts] [css-animations-2][web-animations-2] How should AnimationTrigger work? (#12119)

> With option 1, can you elaborate on how animation.cancel() works? If I cancel before it's triggered? While it's playing? Does it stop the animation from triggering? If so, what is this state and how do I later say that I want it to be triggerable again? When does a trigger become active for a programmatically constructed animation? As soon as the trigger is assigned?

I suggest we discuss each issue on the dedicated issue thread so that we can track and resolve these properly. These questions are discussed in #11914 and I suggested a solution for `cancel()`/`play()` [here](https://github.com/w3c/csswg-drafts/issues/11914#issuecomment-2833295790).

> For 1iii, element.animate should not immediately start playing the animation, it should only result in a trigger that is armed.

This SGTM, but then we may want to propose a change that WAAPI animations are created with a default trigger with `timeline` set to the `DocumentTimeline`, but initially with `state` set to `idle`. And I think that will tie these ends together.

> So CSS and WAAPI animations have the same behavior in this regard.

I think with the above suggestions we can reach that point where they actually do.

> For option 2i and 2ii, I think that pause() should just pause the animation in whatever state its in. If it hasn't triggered yet then it wouldn't trigger even if the condition is met until you call play.

So far I proposed (also in the comment above), as @DavMila also suggested, that calling `pause()`/`play()`/`reverse()` don't affect the behavior of the trigger, but thinking about it again I see how your suggestion also makes sense, and probably makes it more coherent with regard to how these work with CSS Animations.
We could say that calling `pause()` also sets the trigger's state to `idle`. But then calling `play()` again will reset it again instead of allowing it to continue from its current position, so need to consider that.
And we also need to think how `reverse()` works in this context.

> For 2iii I think it would be reasonable to consider it an error condition and throw an error, this is assuming that we have a default trigger of the document timeline which is "always triggered".

In this case then, what is the base-case for a `null` trigger?

> I imagine also that a trigger once animation might finish like a normal animation where a trigger repeat or alternate animation never stops "playing".

I think you mean the animation stays relevant as we proposed in #11971.

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


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

Received on Tuesday, 29 April 2025 18:08:24 UTC