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?
> 

Oh Great question. I think animation.cancel() should have the effects of removing the animation's visual effect and disabling the trigger. For ways to re-enable a trigger, it seems like we'd either need to:
- add an `Animation.enableTrigger` method to do just this. This method would
    -  throw if animation.trigger is null,
    - do nothing if animation.trigger is already enabled,
    - else, enable the trigger.
- or, spec that assigning an animation's [trigger](https://drafts.csswg.org/web-animations-2/#dom-animation-trigger) enables the trigger if the assigned value is not null (though I wonder if it would be weird that `animation.trigger = animation.trigger;` would be a thing that ought to work and that we'd expect authors to write)

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

Hmm, I suppose we could think about it this way but I would have thought a developer calling element.animate signals that they want it to start playing and that this was why, despite animate returning an animation (which a developer could then call play on), animate just directly calls play? 

> 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.

That sounds reasonable but what about code that could have been relying on creating a waapi animation and immediately calling pause in order to keep the animation paused at the initial keyframe before calling play at some other point in time? Would pause still cause the animation to take effect without enabling the trigger under your proposal?
Somewhat separately, I guess this makes pause a way to temporarily disable the trigger while keeping its visual effect, but in a state that isn't advancing, which sounds nice to me.


-- 
GitHub Notification of comment by DavMila
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/12119#issuecomment-2839057406 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 14:03:55 UTC