Skip to content

Commit f7f57ab

Browse files
kevers-googleKevin Ellis
andauthored
[web-animations-2] Preserve animation progress when setting the timeline (w3c#6475)
When switching to a non-monotonic timeline on a paused animation, we set the hold time to preserve the previous progress of the animation to prevent the animation from visually jumping until the animation is unpaused. Co-authored-by: Kevin Ellis <kevers@chromium.org>
1 parent 835c6c8 commit f7f57ab

1 file changed

Lines changed: 21 additions & 5 deletions

File tree

web-animations-2/Overview.bs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,22 @@ follows:
213213
abort this procedure.
214214
1. Let |previous play state| be |animation|'s [=play state=].
215215
1. Let |previous current time| be the |animation|'s [=current time=].
216+
1. Set |previous progress| based in the first condition that applies:
217+
<div class="switch">
218+
219+
: If |previous current time| is unresolved:
220+
221+
:: Set |previous progress| to unresolved.
222+
223+
: If [=end time=] is zero:
224+
225+
:: Set |previous progress| to zero.
226+
227+
: Otherwise
228+
229+
:: Set |previous progress| = <code>|previous current time| /
230+
[=end time=]</code>
231+
</div>
216232
1. Let |from finite timeline| be true if |old timeline| is not null and
217233
not [=monotonically increasing=].
218234
1. Let |to finite timeline| be true if |timeline| is not null and not
@@ -241,14 +257,14 @@ follows:
241257

242258
: If |previous play state| is 'paused':
243259

244-
:: If |previous current time| is resolved:
260+
:: If |previous progress| is resolved:
245261

246262
1. Set the flag |reset current time on resume| to true.
247263
1. Set [=start time=] to unresolved.
248-
1. Set [=hold time=] to |previous current time|.
264+
1. Set [=hold time=] to |previous progress| * [=end time=].
249265

250266
<p class="note">
251-
This step ensures that the [=current time=] is preserved
267+
This step ensures that |previous progress| is preserved
252268
even in the case of a pause-pending animation with a resolved [=start time=].
253269
<p>
254270

@@ -258,10 +274,10 @@ follows:
258274

259275
</div>
260276

261-
: If |from finite timeline| and |previous current time| is resolved,
277+
: If |from finite timeline| and |previous progress| is resolved,
262278

263279
:: Run the procedure to <a>set the current time</a> to
264-
|previous current time|.
280+
|previous progress| * [=end time=].
265281

266282
</div>
267283

0 commit comments

Comments
 (0)