Re: [csswg-drafts] Allow adjacent sets of filling animations to be coalesced

## Proposed solution

First a few prerequisites:

* It would be preferable the solution doesn't produce a lot of special-case code that gets rarely exercised and hence poorly tested (e.g. behavior that only applies when filling multiple additive animations and only when the shape of the arguments doesn't match)
* It would be preferable to avoid any sharp discontinuities when an animation finishes (e.g. making specified values responsive to context while running but not when the animation finishes)
* It would be preferable to make animations do sensible things when using context-sensitive values (i.e. just saying "use computed values all the time" is suboptimal).

And a few observations:

* This problem not only affects additive animations but also animations with implicit keyframes which are very convenient. They are used in CSS transitions (implicit from), in CSS animations (implicit 0%/100% keyframes), in SMIL animation (to-animations) and are popular in techniques such as FLIP animation (which are best written with an implicit to value). Simply saying "Let's abandon composite operations" doesn't solve the problem unless we are also willing to abandon implicit keyframes.
* For the same reason, simply saying "Let's drop per-keyframe composite operations" doesn't solve the problem. Implicit keyframes are essentially keyframes with a zero value and a per-keyframe 'add' composite operation.

I've discussed this with @heycam a little and while I still don't have any really good solutions, my current thinking is:

* Define a concept **fill-able value** that is a representation of a specified value that:
  * Is not context-sensitive
  * Is of such a form that when combining with another fill-able value all operations are associative (I suspect we need more than just "associative" but this math is not my strong point)
* Require that any keyframe set through the API with a composite operation other than 'replace' has its values converted to corresponding fill-able values at the point where there keyframe is set.
* Re-introduce a neutral value / no-op concept.
* Possibly drop 'accumulate' as a composite mode and keep it only as an iteration composite mode. This might not be necessary but if we are to keep it, I will likely need help with the math to prove we can keep it.

As an example, for a transform list value, the fill-able value would be the matrix form of the value. This would only apply for keyframes with a composite mode of 'add' or 'accumulate' (so that most common use cases still work as expected) and the conversion would happen on setting so there is no change in behavior between running and filling. This conversion should ensure we have means of representing a adjacent filling effects that is independent of context and the underlying value. Calculating this value will likely require the use of the neutral / no-op value concept.

I've tried and abandoned a number of other approaches and this is the best I have so far. It's not ideal in that it means you basically can't use `6em` and `composite: add` in a responsive manner but I don't have any better ideas yet (and I actually expect that for some use cases you want the `6em` to _not_ be responsive).

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

Received on Monday, 15 October 2018 07:18:00 UTC