Re: [csswg-drafts] [web-animations-1] Drop the *ReadOnly interfaces

Thinking aloud, what if:

* We track which properties have been overridden on a property-by-property basis . e.g. `cssAnim.effect.updateTiming({ duration: 3000 })` means we'll ignore subsequent changes to the computed value of `animation-duration`.
    * `cssAnim.effect.setTiming(...)` would mean we'll ignore changes to _all_ timing-related properties since it sets them all.
    * `cssAnim.effect.setKeyframes(...)` would likewise mean we ignore changes to `@keyframes` / `animation-name`.
    * We might want to revisit the [quite complex mapping](https://drafts.csswg.org/css-animations-2/#interaction-between-animation-play-state-and-web-animations-API) for `animation-play-state` to make it also follow this once-overridden-always-overridden behavior.
* We _don't_ provide a way to tell which properties have been overridden, or at least not initially.
* We _don't_ provide a way to reset the overridden properties so that they resume tracking changes to markup.
    * In future we could add `cssAnim.effect.resetTiming()` for this and something similar for keyframes, but only if there are use cases/demand for it. That would imply introducing a subclass of `KeyframeEffect` to be used by CSS animations/transitions that includes `resetTiming()` and `resetKeyframes()` since they wouldn't make sense on script-generated animations but that should be fine and possible to introduce later without breaking content--I hope.
* `cssAnim.effect = new KeyframeEffect(...)` continues to break all association with markup except `animation-play-state`.
* We possibly would no longer need the `KeyframeEffect` copy constructor now that it's less common to need to duplicate a `KeyframeEffectReadOnly` in order to get a mutable version. Would `clone()` be a more idiomatic way to create a copy?

    If we don't add this to the API the equivalent JS would be something like:

```js
const clone = new KeyframeEffect(
  src.target,
  Object.assign(src.getTiming(), {
    composite: src.composite,
    iterationComposite: src.iterationComposite,
  }),
  src.getKeyframes()
);
```

Which is complex enough that it's probably worth adding this.

CC @graouts, @flackr, @stephenmcgruer

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

Received on Friday, 12 January 2018 07:41:36 UTC