Re: [csswg-drafts] [web-animations-1] Replace AnimationEffectTiming(ReadOnly) with setTiming() ?

After few further thoughts on this API.

**Observation 1: `updateTiming` feels a little awkward.**

[`setState`](https://reactjs.org/docs/react-component.html#setstate) in React merges the provided keys with the existing state. It might be more natural/familiar to have `setTiming` do likewise and, if necessary, add `replaceTiming` or `resetTiming` to clobber existing state.

I say _if necessary_ because I wonder what the use cases are for resetting all timing where you're not already specifying all the members. e.g. if you're doing `effectA.setTiming(effectB.getTiming())` then you don't need the reset behavior since you're specifying all the members already. React [dropped `replaceState`](https://github.com/facebook/react/issues/3236) since they found it unnecessary and harmful in some cases.

**Observation 2: We may want to introduce `resetTiming` for CSS animations/transitions later**

See discussion in #2068.

The proposal there is we would have a subclass of `KeyframeEffect` used by CSS animations/transitions that adds `resetTiming()` which could be used to make overriden timing properties revert to tracking markup.

One possibility, and this might be a bit too complex, is to introduce `resetTiming` on `AnimationEffect` itself with the behavior that it takes an `EffectTiming` dictionary _without default values_, and for each unspecified value we have the following behavior:

* If this is a markup-bound animation, use the value provided by markup (e.g. `transition-duration`, `animation-duration`) -- basically drop any overidden value.
* Otherwise, use the default value from `DefaultEffectTiming` or whatever we call it.

That way, on a markup-bound animation, `effect.resetTiming()` removes all overrides. On other animations it resets everything, and `effect.resetTiming({ duration: 3000 })` resets everything exception the duration.

I suspect that might be conflating two concepts however, and we should probably have separate methods for resetting to the Web Animations default vs resetting to the markup value.

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

Received on Monday, 15 January 2018 00:13:27 UTC