Re: [csswg-drafts] [web-animations-1] Define requirements for retaining animations to be returned by getAnimations

We've discussed this issue a number of times in the past. Every time we assume there's some quite simple answer and yet we always seem to converge on the following approach.

Requirements:

* For forwards-filling animations there should be some way to see what value is being applied by animation, e.g. for DevTools etc. to explain _why_ the element has the style it does.
* It should be possible to cancel the styles applied by forwards-filling animations. You shouldn't be able to get into a state where you can't clear animation styles (e.g. because you accidentally dropped all the `Animation` handles).
* UAs should be able to use a compact representation for forwards-filling animations--i.e. they should _not_ be required to retain the original `Animation` object of every forwards-filling animation.
* Handles to existing `Animation` objects should continue to be valid, even once the Animation starts filling-forward. i.e. we shouldn't introduce a situation where an `Animation` is completely functional (can be canceled etc.) but becomes suddenly neutered simply by the passing of time.
* The UA's garbage collection should not be observable.

Desirable qualities:

* Uses the same APIs as far as possible to reduce API surface area and allow generic handling of playing and forwards-filling animations (e.g. cancel all animations, get the effect of all animations)

Approach:

* Introduce a new `FillAnimation` subclass of `Animation`.
* All setters on `FillAnimation` throw (or alternative create an `AnimationReadOnly` superclass)?
* All playback methods on `FillAnimation` throw except `cancel()`.
* `fillAnimation.effect.updateTiming()` also throws. (Or coin a new effect for this?)
* `FillAnimation` represents 1 or more forwards-filling animation
* `fillAnimation.effect.getKeyframes()` returns the set of keyframe values being filled. (Do we just specify the 100% keyframe and using timing of `duration: 0; fill: both`?). It may need multiple keyframes if the individual properties have different composite modes.
* `getAnimations()` coalesces as many forwards-filling properties as possible into each `FillAnimation`.
* The object identity of each `FillAnimation` changes only when the set of underlying animations it represents changes. (Not sure if this requirement is necessary.)
* Handles to `Animation`s that are filling forwards and therefore represented by a `FillAnimation` are still usable. Canceling such an `Animation` would cause a new `FillAnimation` to be generated.
* Canceling a `FillAnimation` will cause any `Animation` objects it represents to be canceled.

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

Received on Wednesday, 11 April 2018 09:27:19 UTC