Description
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:
function animator(root, children, timeline) {
// compute frame
}
animator.inputProperties = ['--scroll-position'];
animator.outputProperties = ['opacity'];
or
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