Re: [csswg-drafts] [web-animations-2][css-animations-2] Set of actions for animation triggers (#12611)

@DavMila 
> the [repeat](https://drafts.csswg.org/css-animations-2/#valdef-animation-trigger-behavior-repeat) behavior that currently exists in the spec means "play on enter, reset on exit." In other words, it ties `play()` to the "enter" event and `reset` to "exit" event. This is captured by the `play` and `reset` keywords in the above table, e.g. `animation-trigger: --view-trigger play reset` or even `animation-trigger: --view-trigger replay reset`.

Yes, I'm arguing with that.
So how do we expect `--view-trigger play-pause` and `--view-trigger play-alternate` to behave? Currently they assume `play`/`forwards` on entry and `pause`/`backwards` on exit.
Do we change this behavior to do `play`/`pause` and `forwards`/`backwards` on entry alone?
I'm not sure that's a useful/expected behavior for authors.

Moreover, what happens if you specify both an enter _and_ exit events with a `play-alternate-behavior, like:

```css
.trigger {
  event-trigger: --event-trigger pointerenter / pointerleave;
}

.target {
  animation-trigger: --event-trigger play-alternate;
}
```

This is the same issue again. So what does it mean? Do we duplicate the behavior for `pointerenter`? Or magically map it to both?

So I think we have 2 options here, and the second with 2 sub-options:

1. Remove the `play-*` behaviors altogether, and only allow the alternating behavior explicitly using 2 specified behaviors. So for timeline triggers they map to entry/exit, and for event trigger they alternate based on animation's state.
2. Keep the `play-*` behaviors, add `play-reset` for consistency and also because it's different from `replay`, and decide how they behave with timeline triggers and event trigger pairs:
  i. They map to entry alone, or
  ii. They magically adapt to entry/exit?

Since this is relevant both for timeline triggers and event trigger pairs, I'm kind of between 1 and 2.ii.

------

Aside from that, I think we have another issue with syntax that we overlooked. Since behaviors are space separated, we don't have a way to map a behavior to the exit action alone, e.g. only `pause` on exit.
I also see a couple of options here:

1. Introduce a `/` separator so that you can set `animation-trigger: --view-trigger / pause` for pausing on exit alone. This might be awkward with event triggers perhaps?
2. Introduce a `none` value to allow setting `animation-trigger: --view-trigger none pause`.

Thoughts?

/cc @flackr @fantasai

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


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

Received on Friday, 3 October 2025 13:38:42 UTC