Skip to content

Commit fe001f0

Browse files
committed
[web-animations-1] Fix play an animation procedure
Fixes w3c#7145. This patch makes the following changes: - Consistently applies auto-rewind seeking only when the auto-rewind flag is set. Previously there was an inconsistency where we would not check the auto-rewind flag when the effective playback rate was zero. - Makes the play procedure play an idle animation even when the auto-rewind flag is set to false. - Makes the procedure to seamlessly update an animation's playback rate immediately apply the playback rate if the animation is running but has an unresolved current time and no pending play task, rather than attempting to play such an animation.
1 parent f35d16f commit fe001f0

1 file changed

Lines changed: 44 additions & 28 deletions

File tree

web-animations-1/Overview.bs

Lines changed: 44 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,56 +1142,57 @@ animation.play();</pre></div>
11421142
The procedure to <dfn>play an animation</dfn>, <var>animation</var>, given
11431143
a flag <var>auto-rewind</var>, is as follows:
11441144

1145-
Note: The <var>auto-rewind</var> flag is provided for other specifications
1146-
that build on this model but do not require the rewinding behavior, such
1147-
as CSS Animations [[CSS-ANIMATIONS-1]].
1148-
11491145
1. Let <var>aborted pause</var> be a boolean flag that is true if
11501146
<var>animation</var> has a <a>pending pause task</a>, and false otherwise.
11511147
1. Let <var>has pending ready promise</var> be a boolean flag that is
11521148
initially false.
11531149
1. Let <var>seek time</var> be a <a>time value</a> that is initially <a>unresolved</a>.
1154-
1. Let <var>has finite timeline</var> be true if |animation| has an associated
1155-
<a>timeline</a> that is not [=monotonically increasing=].
1156-
1. Perform the steps corresponding to the <em>first</em> matching
1157-
condition from the following, if any:
1150+
1. If the |auto-rewind| flag is true, perform the steps corresponding to the
1151+
<em>first</em> matching condition from the following, if any:
11581152

11591153
<div class="switch">
11601154

1161-
: If |animation|'s [=effective playback rate=] &gt; 0,
1162-
the <var>auto-rewind</var> flag is true and <em>either</em>
1163-
<var>animation</var>'s:
1155+
: If |animation|'s [=effective playback rate=] &ge; 0,
1156+
and |animation|'s [=animation/current time=] is *either*:
11641157

1165-
* [=animation/current time=] is <a>unresolved</a>, or
1166-
* [=animation/current time=] &lt; zero, or
1167-
* [=animation/current time=] &ge; <a>associated effect end</a>,
1158+
* [=unresolved=], or
1159+
* less than zero, or
1160+
* greater than or equal to [=associated effect end=],
11681161

11691162
:: Set <var>seek time</var> to zero.
11701163

11711164
: If |animation|'s [=effective playback rate=] &lt; 0,
1172-
the <var>auto-rewind</var> flag is true and <em>either</em>
1173-
<var>animation</var>'s:
1165+
and |animation|'s [=animation/current time=] is *either*:
11741166

1175-
* [=animation/current time=] is <a>unresolved</a>, or
1176-
* [=animation/current time=] &le; zero, or
1177-
* [=animation/current time=] &gt; <a>associated effect end</a>,
1167+
* [=unresolved=], or
1168+
* less than or equal to zero, or
1169+
* greater than [=associated effect end=],
11781170
::
11791171
<div class="switch">
11801172

1181-
: If <a>associated effect end</a> is positive infinity,
1182-
:: <a>throw</a> an "{{InvalidStateError}}" {{DOMException}} and
1173+
: If [=associated effect end=] is positive infinity,
1174+
:: [=throw=] an "{{InvalidStateError}}" {{DOMException}} and
11831175
abort these steps.
11841176
: Otherwise,
1185-
:: Set <var>seek time</var> to |animation|'s <a>associated effect end</a>.
1177+
:: Set |seek time| to |animation|'s [=associated effect end=].
11861178

11871179
</div>
11881180

1189-
: If |animation|'s [=effective playback rate=] = 0 and |animation|'s
1190-
[=animation/current time=] is [=unresolved=],
1181+
</div>
11911182

1192-
:: Set <var>seek time</var> to zero.
1183+
1. If the following three conditions are <em>all</em> satisfied:
11931184

1194-
</div>
1185+
* |seek time| is [=unresolved=], and
1186+
* |animation|'s [=start time=] is [=unresolved=], and
1187+
* |animation|'s [=animation/current time=] is [=unresolved=],
1188+
1189+
set |seek time| to zero.
1190+
1191+
Note: The above step ensures that this procedure will play an idle animation
1192+
regardless of the setting of the |auto-rewind| flag.
1193+
1194+
1. Let |has finite timeline| be true if |animation| has an associated
1195+
[=timeline=] that is not [=monotonically increasing=].
11951196

11961197
1. If |seek time| is <a lt=unresolved>resolved</a>,
11971198

@@ -1921,10 +1922,15 @@ The procedure to <dfn>seamlessly update the playback rate</dfn> an
19211922
this case.
19221923

19231924
: If |previous play state| is <a lt="idle play state">idle</a>
1924-
or <a lt="paused play state">paused</a>,
1925+
or <a lt="paused play state">paused</a>, or
1926+
|animation|'s [=animation/current time=] is [=unresolved=],
19251927

19261928
:: [=Apply any pending playback rate=] on |animation|.
19271929

1930+
Note: the second condition above is required so that if we have a
1931+
[=running play state|running=] animation with an unresolved current time
1932+
and no pending play task, we do not attempt to play it below.
1933+
19281934
: If |previous play state| is <a lt="finished play state">finished</a>,
19291935

19301936
:: 1. Let the |unconstrained current time| be the result of calculating
@@ -6380,7 +6386,17 @@ The following changes have been made since the <a
63806386
href="https://www.w3.org/TR/2021/WD-web-animations-1-20210518/">18 May
63816387
2021 Working Draft</a>:
63826388

6383-
(None as yet)
6389+
- Changed the procedure to [=play an animation=] to consistently check
6390+
the *auto-rewind flag* regardless of the [=effective playback rate=].
6391+
Previously the flag was not checked when the effective playback rate was
6392+
zero.
6393+
6394+
- Changed the procedure to [=play an animation=] to ensure an idle animation
6395+
is played even when the *auto-rewind flag* is false.
6396+
6397+
- Changed the procedure to [=seamlessly update the playback rate=] so that it
6398+
does not attempt to play an animation with a resolved start time but an
6399+
unresolved current time and no pending play task (i.e. a running animation).
63846400

63856401
The <a
63866402
href="https://github.com/w3c/csswg-drafts/commits/main/web-animations-1">changelog</a>

0 commit comments

Comments
 (0)