Skip to content

Commit da4b585

Browse files
authored
[web-animations-1] Make async methods on Animation return appropriate Promise objects (#2799)
This closes #2206.
1 parent 5914309 commit da4b585

File tree

1 file changed

+27
-13
lines changed

1 file changed

+27
-13
lines changed

web-animations-1/Overview.bs

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,8 +1245,7 @@ as CSS Animations [[CSS-ANIMATIONS-1]].
12451245
implementations:
12461246

12471247
<div class='example'><pre class='lang-javascript'>
1248-
animation.play();
1249-
animation.ready.then(
1248+
animation.play().then(
12501249
() => { console.log('Playback commenced'); },
12511250
() => { console.log('Playback was canceled'); }
12521251
);
@@ -3953,10 +3952,10 @@ interface Animation : EventTarget {
39533952
attribute EventHandler oncancel;
39543953
void cancel ();
39553954
void finish ();
3956-
void play ();
3957-
void pause ();
3958-
void updatePlaybackRate (double playbackRate);
3959-
void reverse ();
3955+
Promise&lt;Animation&gt; play ();
3956+
Promise&lt;Animation&gt; pause ();
3957+
Promise&lt;Animation&gt; updatePlaybackRate (double playbackRate);
3958+
Promise&lt;Animation&gt; reverse ();
39603959
};
39613960
</pre>
39623961

@@ -4071,35 +4070,46 @@ interface Animation : EventTarget {
40714070

40724071
</div>
40734072

4074-
: <dfn method for=Animation lt='play()'>void play()</dfn>
4075-
:: Unpauses the animation and rewinds if it has finished playing using
4076-
the procedure to <a>play an animation</a> for this object
4077-
with the <var>auto-rewind</var> flag set to true.
4078-
: <dfn method for=Animation lt='pause()'>void pause()</dfn>
4073+
: <dfn method for=Animation lt='play()'>Promise&lt;Animation&gt; play()</dfn>
4074+
:: Begins or resumes playback of the animation by running the procedure to
4075+
[=play an animation=] passing true as the value of the |auto-rewind| flag.
4076+
4077+
Returns the animation's [=current finished promise=] at the moment
4078+
immediately after performing the [=play an animation=] procedure.
4079+
: <dfn method for=Animation lt='pause()'>Promise&lt;Animation&gt; pause()</dfn>
40794080
:: Suspends the playback of this animation by running the procedure to
40804081
<a>pause an animation</a> for this object.
4081-
: <dfn method for=Animation lt='updatePlaybackRate(playbackRate)'>void updatePlaybackRate(playbackRate)</dfn>
4082+
4083+
Returns the animation's [=current ready promise=] at the moment
4084+
immediately after performing the [=pause an animation=] procedure.
4085+
: <dfn method for=Animation lt='updatePlaybackRate(playbackRate)'>Promise&lt;Animation&gt; updatePlaybackRate(playbackRate)</dfn>
40824086
:: Performs an asynchronous update of the [=playback rate=] of this
40834087
animation by performing the [=seamlessly update the playback rate=]
40844088
procedure, passing
40854089
{{Animation/updatePlaybackRate(playbackRate)/playbackRate}} as the |new
40864090
playback rate|.
40874091

4092+
Returns the animation's [=current ready promise=] at the moment immediately
4093+
after performing the [=seamlessly update the playback rate=] procedure.
4094+
40884095
<div class="parameters">
40894096

40904097
: <dfn argument for="Animation/updatePlaybackRate(playbackRate)"
40914098
lt="playbackRate">playbackRate</dfn>
40924099
:: A finite real number specifying the updated playback rate to use.
40934100

40944101
</div>
4095-
: <dfn method for=Animation lt='reverse()'>void reverse()</dfn>
4102+
: <dfn method for=Animation lt='reverse()'>Promise&lt;Animation&gt; reverse()</dfn>
40964103
:: Inverts the [=playback rate=] of this animation and plays it using the
40974104
<a>reverse an animation</a> procedure for this object.
40984105
As with <a method for=Animation lt="play()">play()</a>, this
40994106
method unpauses the animation and, if the animation has already finished
41004107
playing in the reversed direction, seeks to the start of the <a>target
41014108
effect</a>.
41024109

4110+
Returns the animation's [=current finished promise=] at the moment
4111+
immediately after performing the [=reverse an animation=] procedure.
4112+
41034113
</div>
41044114

41054115
<h4 id="the-animationplaystate-enumeration">The <code>AnimationPlayState</code> enumeration</h4>
@@ -5959,6 +5969,10 @@ The following changes have been made since the <a
59595969
{{AnimationEffect/updateTiming}} method.
59605970
* Removed <code>KeyframeEffectReadOnly</code>, leaving only
59615971
{{KeyframeEffect}}.
5972+
* Made the {{Animation/play()}} and {{Animation/reverse()}} methods on
5973+
{{Animation}} return the animation's [=current finished promise=],
5974+
and the {{Animation/pause()}} and {{Animation/updatePlaybackRate()}} methods
5975+
return the animation's [=current ready promise=].
59625976
* Added special handling to allow animating the 'offset' property from the
59635977
programming interface using <code>cssOffset</code> to avoid conflict with
59645978
the attribute name used to specify keyframe offsets.

0 commit comments

Comments
 (0)