[css-animationworklet] Separate Stateful and Stateless animator interfaces #812#827
Conversation
stephenmcgruer
left a comment
There was a problem hiding this comment.
This seems reasonable to me. I am assuming you have already considered the benefits of having this inheritance approach versus, say, a static member variable or an argument to the WorkletAnimation constructor. (I think baking it into the worklet is probably better, I can't think of a reason for the same code to be reused for stateful and stateless).
|
|
||
| A user-defined stateful animator is expected to fulfill the required contract which is that its | ||
| state attribute is an object representing its state that can be serialized using structured | ||
| serialized algorithm and that it can also re-generatea its state given that same object passed to |
There was a problem hiding this comment.
Typo: re-generate, but would actually suggest "recreate".
There was a problem hiding this comment.
Done. Using recreate.
| <pre class='lang-javascript'> | ||
| class BarAnimator extends StatefulAnimator { | ||
| constructor(options, state) { | ||
| // Called when a new animator is instantiated (either first time of after being respawned). |
There was a problem hiding this comment.
Typo: 'first time or after'
| An <dfn>Animator</dfn> represents an animation instance that is running on animation thread. Animators | ||
| are identified by a unique name and determine how the animation progresses its keyframe effects | ||
| given current input time. <a>Animator</a> instances live in {{AnimationWorkletGlobalScope}} and | ||
| each one is associated with a {{WorkletAnimation}} instance. An animator can only be instantiated |
There was a problem hiding this comment.
(Just for my own clarification, I suppose a WorkletAnimation is the main thread instance?)
There was a problem hiding this comment.
That is correct. I took a mental note to make this relationship more clear (perhaps even add a diagram).
|
|
||
| </div> | ||
|
|
||
| Note: If an animator state getter throws the user agent will remove the animator but does not |
There was a problem hiding this comment.
Is this normative text? If so, perhaps it shouldn't be a note?
There was a problem hiding this comment.
This was to make it clear that this is effectively the implication of the algorithm above. I remove the note to make it clear it is normative.
|
Thanks @birtles and @stephenmcgruer for feedback 👍 . I made corrections accordingly. |
Fixes issue #812 .
StatefulAnimatorandStatelessAnimator. Add sections to describe the difference.