Re: [csswg-drafts] [css-animations] Extend animation-play-state for triggering animations when an element is in viewport (#8942)

Yehonatan and I discussed this IRL while both at CSS Day. Must say I like the general idea of using `animation-play-state` for this:

- It hints at “this is a regular animation, but it’ll only play from a certain point (in space)”
- It correctly assumes to not be a timeline – so doesn’t fit into `animation-timeline` – because the animation would still run on the document timeline.
- It doesn’t require a parent container or anything
- `animation-duration` will still have its meaning

Good remark by Brian on not overloading `animation-fill-mode` for this. Perhaps the “trigger once” thing could be a flag in the triggering function.

As for bikeshedding: I would name the function `trigger()` instead of `toggle()`.

FWIW: an alternative idea I had in the back of my mind somewhere was to adjust `animation-duration` to accept something like `trigger(5s, entry 10%)` but that seems more convoluted than Yehonatan’s proposal.

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


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

Received on Monday, 12 June 2023 11:00:31 UTC