[csswg-drafts] [web-animations-2] Custom effects (#6861)

graouts has just created a new issue for https://github.com/w3c/csswg-drafts:

== [web-animations-2] Custom effects ==
I would like to revive work on [custom effects](https://drafts.csswg.org/web-animations-2/#custom-effects), an idea currently unofficially drafted in [Web Animations Level 2](https://drafts.csswg.org/web-animations-2/). I have filed a [patch for WebKit](https://bugs.webkit.org/show_bug.cgi?id=233869) to support the `CustomEffect` interface as well as a new `document.timeline.animate()` method. The motivation is to bridge the gap between the poorly-named and rudimentary `requestAnimationFrame()` and Web Animations allowing authors to harness the full power of the Web Animations model such that scripted animations may be paused, resumed, seeked, etc.

Some example usage:

```javascript
const animation = new Animation;
animation.effect = new CustomEffect(progress => { … }, 1000);
animation.play();
```

This code is equivalent to the more idiomatic:

```javascript
document.timeline.animate(progress => { … }, 1000);
```

The idea here is that `document.timeline.animate()` should be to `CustomEffect` what `element.animate()` is to `KeyframeEffect`.

The section on [custom effects](https://drafts.csswg.org/web-animations-2/#custom-effects) in the current level 2 spec starts with this issue:

> This whole feature needs to be revisited. The current thinking is that rather than having custom effects, we should simply have an onupdate callback on each animation effect. That would allow, for example, augmenting an existing effect with a function that performs logging or triggers additional actions at certain times. With the current arrangement, doing this would require adding a parent group just to achieve this.

I personally think that a dedicated `CustomEffect` interface is a simple and purposeful way to specify an animation where its _application_ is performed by script. I expect that it is simpler to specify how this specific class of effects would work rather than trying to add an `onupdate` callback that would apply to keyframe effects as well.

You'll also notice the lack of a `target` for `CustomEffect`. I believe that it should not be necessary to specify a target for a custom effect since it may not target a single node, or even a node at all, but rather a JS object controlling the rendering of a scene using `<canvas>` APIs.

That being said, I am very open to all feedback to work towards exposing callback-based animations in Web Animations. All work conducted in WebKit is behind an off-by-default _experimental feature_ flag and we have no intention to expose this to the Web until we have consensus on the way forward.

Cc @birtles @flackr @stephenmcgruer @kevers-google @majido @smfr @grorg @hober @ogerchikov. I'm not sure who would be a good person to Cc at Mozilla for animation-related topics.

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/6861 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Monday, 6 December 2021 10:57:40 UTC