Re: [csswg-drafts] [css-animations-2][scroll-animations-1] Keyframe ordering and ordering requirements (#8507)

The CSS Working Group just discussed `[css-animations-2][scroll-animations-1] Keyframe ordering and ordering requirements`, and agreed to the following:

* `RESOLVED: Collapse keyframes with same specified offset to the earlier one, then pull percentage-only keyframes to the front and sort them`

<details><summary>The full IRC log of that discussion</summary>
&lt;fantasai> s/Topic/Subtopic/<br>
&lt;fantasai> s/Topic/Subtopic/<br>
&lt;emilio> flackr: css-animations defines that there's a sorting of keyframes by offset<br>
&lt;fantasai> i/scribenick/Topic: Scroll Animations/<br>
&lt;emilio> ... timeline-range keyframes have effectively dynamic offsets<br>
&lt;emilio> ... further, web-animations requires keyframes to be sorted and throws if not<br>
&lt;emilio> ... proposal is for css animations if you look at keyframes you'll sort by the computed offset which means that the keyframe order can switch depending on layout offsets<br>
&lt;emilio> ... we shouldn't merge keyframes with same computed offset but different specified offsets<br>
&lt;emilio> ... there's an exception already for different composite modes and easing<br>
&lt;emilio> ... if you have a not-computed offset<br>
&lt;emilio> ... I'm proposing we just keep them in the stable sort order relative to the other keyframes around them<br>
&lt;emilio> ... so basically you do a stable sort but keyframes with no offset are not comparable<br>
&lt;emilio> q+<br>
&lt;emilio> flackr: there'd be no changes for web animations, what you pass is what you get, and we'd relax the requirement to specify them in order<br>
&lt;emilio> ... so that only fixed offsets need to be sorted<br>
&lt;Rossen_> ack fantasai<br>
&lt;emilio> fantasai: so you're proposing that whatever keyframes get passed in and if they don't have a resolvable offset do they get dropped?<br>
&lt;emilio> flackr: they're dropped from the animation but getKeyframes would still return them as described above<br>
&lt;Rossen_> ack emilio<br>
&lt;fantasai> emilio: Does this mean that calling getKeyframes now needs to do a layout update, rather than just styling?<br>
&lt;fantasai> flackr: yes, if the animation has range-based keyframes, it needs a layout update...<br>
&lt;fantasai> flackr: I believe that at least Chrome didn't differentiate between style and layout in this case<br>
&lt;fantasai> emilio: I'm pretty sure we do<br>
&lt;fantasai> emilio: Chrome doesn't have such a strong difference between update style vs layout<br>
&lt;fantasai> emilio: but we do have that difference<br>
&lt;fantasai> emilio: although container queries make that tricky<br>
&lt;emilio> fantasai: would it make sense not to do the layout-based sort?<br>
&lt;emilio> fantasai: so percentage-based keyframes are sorted but the others remain stable<br>
&lt;fantasai> emilio: I think that might be slightly preferable<br>
&lt;fantasai> emilio: the less we need to update for DOM APIs the better<br>
&lt;ydaniv> q+<br>
&lt;chris> regrets+ lea<br>
&lt;emilio> fantasai: why are we sorting these at all? Can we have the API not sort them?<br>
&lt;emilio> flackr: for WebAnimations it asserts that they're sorted, which we need to relax<br>
&lt;emilio> ... for CSS animations it's spec'd that we'd sort the keyframes by the percentage specified<br>
&lt;emilio> ... this is observable and it'd be hard to know whether it's compatible to change that<br>
&lt;emilio> fantasai: what if we zero out the dynamic offsets when sorting so that we have a canonical order?<br>
&lt;emilio> ... if there's a percentage offset we sort by that but for range we treat as zero<br>
&lt;emilio> flackr: I feel like if we treat range separate we can just leave them in the specified order<br>
&lt;emilio> ... I think the main reason keyframes are sorted by percent is for merging and we don't want to merge these<br>
&lt;emilio> YehonatanDaniv: the only case offsets could change dependent on layout is changing ?? to cover<br>
&lt;emilio> ... I think that's the only case which is kind of minor<br>
&lt;emilio> flackr: anything other than cover computes its offset based on the timeline<br>
&lt;Rossen_> ack ydaniv<br>
&lt;fantasai> flackr: cover is the only case where the % specified is equivalent to the percentage in the timeline<br>
&lt;fantasai> flackr: otherwise the % is dependent on layout<br>
&lt;fantasai> flackr: e.g. range of 100% is dependent on the element size<br>
&lt;fantasai> YehonatanDaniv: larger or smaller than viewport?<br>
&lt;fantasai> flackr: any change in the element's height changes what 'enter 100%' results in<br>
&lt;fantasai> YehonatanDaniv: but that doesn't change the order of keyframes<br>
&lt;fantasai> flackr: ah, yes. If you have keyframes of multiple ranges specified<br>
&lt;fantasai> YehonatanDaniv: I think if the only edge case is missing one of the 1st three with cover, then reasonable not to update the order of the keyframes according to layout changes<br>
&lt;bramus> q+<br>
&lt;fantasai> YehonatanDaniv: we have duration and currentTime update, but order of keyframes doesn't need to change in most cases<br>
&lt;fantasai> flackr: but the question is what should spec say about order of keyframes?<br>
&lt;fantasai> YehonatanDaniv: I think everything else still holds, we have logical order of entry/contain/exit, and then entry-crossing/exit-crossing<br>
&lt;fantasai> flackr: there's overlap among those phases, and cover covers all of them<br>
&lt;fantasai> YehonatanDaniv: cover is the special case<br>
&lt;fantasai> flackr: entry-crossing and exit-crossing are also special<br>
&lt;fantasai> flackr: one possibility is we could have sort by range name and then percentage<br>
&lt;fantasai> flackr: that defines a DOM ordering<br>
&lt;fantasai> flackr: or we could leave them as specified in the CSS<br>
&lt;fantasai> flackr: which is consistent with what we do when keyframes have different easings or composit modes<br>
&lt;fantasai> flackr: they stay in their specified order<br>
&lt;fantasai> flackr: so in the absence of any reason to sort we use the specified order<br>
&lt;fantasai> YehonatanDaniv: ok, by range name and offset, but need to clarify regarding special cases<br>
&lt;fantasai> flackr: the other reason that sorting matters is it affects which keyframe values are active for a particular range<br>
&lt;fantasai> flackr: if 2 keyframes compute to 20%, when you're after 20%, which keyframe's values are you getting?<br>
&lt;fantasai> flackr: if one says 'bg: green' other is 'bg: blue', need to know which is later to know what color to get<br>
&lt;fantasai> flackr: my proposal is in all complex cases we use specified order<br>
&lt;fantasai> flackr: that removes layout order, and produces a well-defined animation<br>
&lt;fantasai> YehonatanDaniv: consistent also with [missed]<br>
&lt;fantasai> flackr: consistent with what we do with easing and composit mode<br>
&lt;fantasai> bramus: Also wanted to point out order can change if size of scroller changes<br>
&lt;emilio> bramus: wanted to point out that order of the keyframes can change if size of scroller changes<br>
&lt;fantasai> bramus: e.g. 'enter 100%' and exit animation starts when scroller becomes too small<br>
&lt;Rossen_> ack bramus<br>
&lt;fantasai> bramus: authors can predict what happens, so I'm in favor of this proposal<br>
&lt;emilio> fantasai: I wanted to ask what the proposal is? Don't sort other than the percentage based ones? If two keyframes have the same offset even in different phases we don't merge them?<br>
&lt;emilio> flackr: we won't merge if they have the same computed offset<br>
&lt;emilio> fantasai: even if they have the same specified offset?<br>
&lt;emilio> flackr: we can merge then, it's not complex and is consistent with the expectations for other animations<br>
&lt;emilio> fantasai: I think we could propose that keyframes with the same specified offset are merged<br>
&lt;emilio> fantasai: what happens if there's interleaved keyframes and ranged?<br>
&lt;emilio> flackr: the index of the specified keyframe is the secondary sort order<br>
&lt;emilio> fantasai: so say I have 0%, entry, 0%, entry, 20%, entry, 50%<br>
&lt;Rossen_> q?<br>
&lt;fantasai> 20%, entry 50%, 0%, entry 0%, entry 6em<br>
&lt;Rossen_> ack fantasai<br>
&lt;emilio> flackr: I was wondering if we could be really naive and use stable sort where values are equal if any value has ranges<br>
&lt;emilio> ... so only the 0% will move before the 20%<br>
&lt;emilio> flackr: for applying the animation later we need to sort by computed offset<br>
&lt;emilio> fantasai: right but you want percentages in order, but ranges don't matter<br>
&lt;emilio> ... so do you ?? or move all the percentages first?<br>
&lt;emilio> flackr: I think percentages at the beginning would be simplest<br>
&lt;emilio> fantasai: I think otherwise you need to chop up the list and sort the fragments<br>
&lt;Rossen_> 0%, 20%, entry 50%, entry 0%, entry 6em<br>
&lt;fantasai> Percentages at the beginning option: 0%, 20%, entry 50%, entry 0%, entry 6em<br>
&lt;fantasai> Segmented list option: 0%, entry 0%, entry 6em, 20%, entry 50%<br>
&lt;emilio> flackr: my concern with the segmented option is that percentages are not guaranteed to be sorted among them<br>
&lt;emilio> fantasai: I'm not sure it makes sense, I'm saying "I'm a complex list so my order is whatever"<br>
&lt;emilio> flackr: I'm not sure it makes sense to do that<br>
&lt;emilio> q+<br>
&lt;fantasai> s/whatever/that of the most recently-specified raw percent keyframe/<br>
&lt;fantasai> emilio: I was going to say that seems more simple and intuitive to me<br>
&lt;Rossen_> ack emilio<br>
&lt;fantasai> emilio: put percentages at the beginning, then sort the rest<br>
&lt;fantasai> PROPOSAL: Collapse keyframes with same specified offset to the earlier one, then pull percentage-only keyframes to the front and sort them<br>
&lt;emilio> RESOLVED: Collapse keyframes with same specified offset to the earlier one, then pull percentage-only keyframes to the front and sort them<br>
&lt;fantasai> Rossen_: OK, we're resolved. As you get more experience with this, let us know if it works<br>
</details>


-- 
GitHub Notification of comment by css-meeting-bot
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/8507#issuecomment-1476358844 using your GitHub account


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

Received on Monday, 20 March 2023 14:41:06 UTC