@@ -223,7 +223,7 @@ interface StatelessAnimator {
223
223
<div class='note'>
224
224
This is how the class should look.
225
225
<pre class='lang-javascript'>
226
- class FooAnimator extends StatelessAnimator{
226
+ class FooAnimator extends StatelessAnimator {
227
227
constructor(options) {
228
228
// Called when a new animator is instantiated.
229
229
}
@@ -253,21 +253,21 @@ effect is mutable only in a certain thread). Animation worklet guarantees that a
253
253
instance's state is maintained even if the instance is respawned in a different global scope.
254
254
255
255
The basic mechanism for maintaining the state is that the animation worklet snapshots the local
256
- state that is exposed via {{StatefulAnimator/state}} attribute and then reifies it at a later time
257
- to be passed into the constructor when the animator instance is respawned in a potentially different
258
- global scope. This processes is specified is details in <a>migrate an animator instance</a>
259
- algorithm .
256
+ state that is exposed via the {{StatefulAnimator/state}} function and then reifies it so that it can
257
+ be passed into the constructor when the animator instance is respawned at a later time in a
258
+ potentially different global scope. The <a>migrate an animator instance</a> algorithm specifies this
259
+ process in details .
260
260
261
261
A user-defined stateful animator is expected to fulfill the required contract which is that its
262
- state attribute is an object representing its state that can be serialized using structured
262
+ state function returns an object representing its state that can be serialized using structured
263
263
serialized algorithm and that it can also recreate its state given that same object passed to
264
264
its constructor.
265
265
266
266
<xmp class='idl'>
267
267
[Exposed=AnimationWorklet, Global=AnimationWorklet,
268
268
Constructor (optional any options, optional any state)]
269
269
interface StatefulAnimator {
270
- attribute any state;
270
+ any state() ;
271
271
};
272
272
</xmp>
273
273
@@ -284,7 +284,7 @@ interface StatefulAnimator {
284
284
// Animation frame logic goes here and can rely on this.currentVelocity.
285
285
this.currentVelocity += 0.1;
286
286
}
287
- get state {
287
+ state() {
288
288
// The returned object should be serializable using structured clonable algorithm.
289
289
return {
290
290
velocity: this.currentVelocity;
@@ -348,7 +348,7 @@ following steps:
348
348
349
349
350
350
5. If <a>SameValue</a> (|prototype|, {{StatelessAnimator}} ) is <b> true</b> set |stateful| to be
351
- <b> false</b> , otherwise if <a>SameValue</a> (|prototype|, {{StatefulAnimator}} ) is
351
+ <b> false</b> , otherwise if <a>SameValue</a> (|prototype|, {{StatefulAnimator}} ) is
352
352
<b> true</b> set |stateful| to be <b> true</b> , otherwise <a>throw</a> a <a>TypeError</a> and
353
353
abort all these steps.
354
354
@@ -534,8 +534,9 @@ To <dfn>migrate an animator instance</dfn> from one {{WorkletGlobalScope}} to an
534
534
535
535
4. If |stateful| is <b> false</b> then abort the following steps.
536
536
537
- 5. Let |state| be the result of <a>Get</a> (|instance|, "state"). If any exception is thrown,
538
- rethrow the exception and abort the following steps.
537
+ 5. Let |state| be the result of <a>Invoke</a> |stateFunction| with |instance| as the
538
+ <a>callback this value</a> . If any exception is thrown, rethrow the exception and abort
539
+ the following steps.
539
540
540
541
6. Set |serializedState| to be the result of <a>StructuredSerialize</a> (|state|).
541
542
If any exception is thrown, then abort the following steps.
0 commit comments