Re: [csswg-drafts] [css-animations-2] Proposal: Time-based Keyframe Animations (#4907)

`animation-playback-rate: auto` is nice for allowing scaling with `animation-duration`.

However per the [current spec](https://www.w3.org/TR/css-animations-2/#animation-duration): 
_`animation-duration`: ... For time-driven animations, specifies the length of time that an animation takes to complete one cycle._

With that in mind, having `animation-duration: <time>` change the playback rate/speed to complete all the time-based keyframes within one cycle makes sense to me.

If the desire is for cutting an animation short, then a separate way for selecting the start and end of the keyframes seems appropriate for showing a segment of an animation. Haven't fleshed this out entirely, but initial thoughts would be:

```
  animation-segment: auto auto; /* Start at first keyframe, end at last keyframe. Equivalent to `animation-segment-start: auto; animation-segement-end: auto` */
  animation-segment: auto 5s; /* Clip a time-based keyframe animation to the first 5 seconds */
  animation-segment: 1s 2s; /* Clip time-based keyframes to only from 1s to 2s */
  animation-segment: auto 50%; /* Clip to the first half of the animation (regardless of time/percentage keyframes) */
  animation-segment: 50% auto; /* Clip to the last half of the animation (regardless of time/percentage keyframes) */
```
`animation-duration: auto` could take the `animation-segment` into account so `animation-segment: auto 5s` would be `5s` duration and `animation-segment: 1s 2s;` would be `1s` duration.

A property like this could be useful for percentage keyframes, time keyframes, and scroll animations. 

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


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

Received on Friday, 10 January 2025 16:48:14 UTC