Re: [csswg-drafts] [css-animations-2] Move scroll and event animation triggers to independent namespace (#12336)

> It seems like a cleaner way to organize the properties so we don't have a longhand (animation-trigger-event or animation-trigger-timeline) which may or may not be relevant to the trigger. I'm not sure if there is precedent for setting one longhand property because another one is set, but that seems like something we should avoid if we can? Without doing that, we have to arbitrarily decide whether animation-trigger-event takes precedence over animation-trigger-timeline when both are set.

Yes, it's not optimal, but you can see we already have a syntax like `auto | [ <timeline> <ranges> ]`, so ranges are not allowed with `auto`. So if both are specified this becomes invalid at parse-time. Same with my suggestion above that includes `event(<dashed-ident>)`.

> One point that might be worth highlighting in this scheme is how an author could write the following:
>
```css
#a { view-timeline-name: --mytl; }
#b { timeline-trigger: --mytr --mytl; }
#c { animation-trigger: --mytr repeat; }
```
>
> In which case, if element b disappears, then so does the trigger. I don't think this is much of a problem; it just doesn't seem like it would be useful.

The thing we need to acknowledge here is that **triggers are not directly associated with elements**. And IMO making their declaration a separate property is not a good design.
Of course, if we just take the trivial case of declaring timelines with `scroll()`/`view()` then we sort of try to avoid that issue, but like your example above, if an author defines the timeline on one element and references it on the trigger, then the trigger declaration becomes an annoyance.

Regarding scoping, I think if we want to add events to be consumed similarly to timelines then we should have a similar API for events as for timelines, with declaration on elements and a specialized scoping declaration. And then consume those in triggers, same as we do now with timelines.

-- 
GitHub Notification of comment by ydaniv
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/12336#issuecomment-3015135159 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 09:16:11 UTC