[css-houdini-drafts] Pure/idempotent representation

majido has just created a new issue for https://github.com/w3c/css-houdini-drafts:

== Pure/idempotent representation ==
_From @appsforartists on September 27, 2016 18:50_

The animators in the README use the `class` keyword and static properties to construct an animation worklet.  For animators that remember state across frames (#4), this seems reasonable.  However, many animators will be pure transformations of input to output.  For both readability/stylistic purposes and to avoid needlessly allocating memory/CPU cycles, it may be desirable to have an alternate representation for pure animators.

Perhaps:

``` javascript
function animator(root, children, timeline) {
  // compute frame
}

animator.inputProperties = ['--scroll-position'];
animator.outputProperties = ['opacity'];
```

or 

``` javascript
const animator = { 
  inputProperties: [
    '--scroll-position',
  ],
  outputProperties: [
    'opacity',
  ],
  animate(root, children, timeline) {
    // compute frame
  },
}
```

**NOTE:** The present API is also mutative - output is expressed by settings properties on the input, not by returning values.  Some authors will prefer a truly pure API, but that's more a matter of style than of minimizing resource usage.


_Copied from original issue: WICG/animation-worklet#14_

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

Received on Wednesday, 29 August 2018 18:18:44 UTC