Description
Overview
We need to define the order of keyframes from CSS animations and any requirements when constructing JS animations. Prior to timeline range keyframe selectors we have the following rules:
css-animations-2 Section 3. Keyframes performs a stable sort by offset (step 6), and merges keyframes with matching keyframe offset, timing function and composite (step 6.4). The result is exposed via the web-animations-1 getKeyframes method.
web-animations-1 Section 6.6.3. Processing a keyframes argument procedure to process a keyframes argument step 6 throws a TypeError if the supplied offsets of the keyframes are not sorted.
With timeline range keyframe selectors the order of keyframes is not known until after layout and may change with changes to the layout. As such, we have to decide how to handle this.
I wrote a short demo to show the observed keyframes at https://jsbin.com/zofukin/edit?html,css,js,output
Proposal
For css animations:
- just as differences in composite and the timing function do not allow two keyframe blocks to be merged, we should consider named range offsets to only be mergeable with the exact same specified named range offset.
- Keyframes should continue to be sorted by a stable sort, though it will need to be a sort of their computed offsets.
- Where do we sort keyframes whose offsets are not computable? They could be kept in their stable position ignoring offset or they could be effectively removed not appearing in getKeyframes. Naively, I'd propose keeping them in their stable sorted position and visible in the API.
For web animations, we never modify the passed in keyframes. They are returned in the order specified with specified offsets. We can't enforce the ordering requirement as strictly. We could do one of the following:
- Only require ordering of keyframes with overall percentage offsets, allow other keyframes in any order.
- Require ordering of keyframes within each named offset range. E.g. two keyframes on the
cover
range must be ordered with respect to each other. Though this gets more complicated when you consider that offsets will support calculations in the future.
I lean towards the first since calculations will also break the ability to ensure that order is correct when specified.