Skip to content

Commit

Permalink
[web-animations-1] Restore compensatory seek to playbackRate setter
Browse files Browse the repository at this point in the history
This fixes #2266.
  • Loading branch information
birtles committed Feb 8, 2018
1 parent a885471 commit 673f6fc
Showing 1 changed file with 28 additions and 29 deletions.
57 changes: 28 additions & 29 deletions web-animations-1/Overview.bs
Expand Up @@ -1735,29 +1735,31 @@ is as follows:

1. Clear any [=pending playback rate=] on |animation|.

1. Set the [=playback rate=] of <a>animation</a> to <var>new playback
rate</var>.
1. Let <var>previous time</var> be the value of the
<a>current time</a> of <var>animation</var> before changing the
[=playback rate=].

1. Run the procedure to <a>update an animation's finished state</a> for
<var>animation</var> with the <var>did seek</var> flag set to true, and
the <var>synchronously notify</var> flag set to false.
1. Set the [=playback rate=] to <var>new playback rate</var>.

Note: We don't need to update the <a>previous current time</a> before
calling this since we set the <var>did seek</var> flag to true meaning we
will ignore the <a>previous current time</a>.
1. If <var>previous time</var> is <a lt="unresolved">resolved</a>,
<a>set the current time</a> of <var>animation</var> to
<var>previous time</var>

<h5 id="performing-seamless-updates-to-the-playback-rate-of-an-animation">Performing seamless updates to the playback rate of an animation</h5>

For an animation whose <a>current time</a> is not zero, the procedure to <a>set
the playback rate</a> may result in a sharp change to the animation's
current time causing the animation to jump.
For an in-flight animation that is running on another process or thread, the
procedure to <a>set the playback rate</a> may cause the animation to jump if the
process or thread running the animation is not currently synchronized with the
process or thread performing the update.

In order to produce seamless changes to the [=playback rate=] of an
[=animation=], animation's may have a <dfn>pending playback rate</dfn> that
defines a playback rate to be applied after any necessary synchronization has
taken place (for the case of animations running in a different thread or
process).

Initially the [=pending playback rate=] of an [=animation=] is unset.

When an [=animation=], |animation|, is to <dfn>apply any pending playback
rate</dfn> the following steps are performed:

Expand Down Expand Up @@ -1892,8 +1894,9 @@ condition from the following:
<var>animation</var> is <a>unresolved</a> <em>and</em> it does
<em>not</em> have a <a>pending play task</a>,
:: &rarr; <dfn lt="paused play state">paused</dfn>
: For <var>animation</var>, <a>current time</a> is <a>resolved</a> and
<em>either</em> of the following conditions are true:
: For <var>animation</var>, <a>current time</a> is <a
lt=unresolved>resolved</a> and <em>either</em> of the following conditions
are true:
* [=playback rate=] &gt; 0 and
<a>current time</a> &ge; <a>target effect end</a>; <em>or</em>
* [=playback rate=] &lt; 0 and
Expand Down Expand Up @@ -4002,16 +4005,14 @@ interface Animation : EventTarget {

<div class=note>

Setting this attribute is only intended for low-level synchronization
of animations.
It does <em>not</em> preserve the {{Animation/currentTime}} of the animation
nor make any attempt to synchronize with the playback state of animations
running on a separate process or thread.
Setting this attribute performs a synchronous update to the [=playback
rate=] meaning that it does not make any attempt to synchronize with the
playback state of animations running on a separate process or thread.
As a result, setting the {{Animation/playbackRate}} for an in-flight
animation may cause it to jump.

To set the the [=playback rate=] for an in-flight animation such that it
continues to play from its current position, use {{updatePlaybackRate()}}.
smoothly updates, use the asynchronous {{updatePlaybackRate()}} method.

</div>

Expand Down Expand Up @@ -4058,11 +4059,11 @@ interface Animation : EventTarget {
:: Suspends the playback of this animation by running the procedure to
<a>pause an animation</a> for this object.
: <dfn method for=Animation lt='updatePlaybackRate(playbackRate)'>void updatePlaybackRate(playbackRate)</dfn>
:: Updates the [=playback rate=] of this
animation such that it maintains its <a>current time</a> by performing the
<a>seamlessly update the playback rate</a> procedure, passing
{{Animation/updatePlaybackRate(playbackRate)/playbackRate}} as the <var>new
playback rate</var>.
:: Performs an asynchronous update of the [=playback rate=] of this
animation by performing the [=seamlessly update the playback rate=]
procedure, passing
{{Animation/updatePlaybackRate(playbackRate)/playbackRate}} as the |new
playback rate|.

<div class="parameters">

Expand Down Expand Up @@ -6085,11 +6086,9 @@ The following changes have been made since the <a
(<a href="https://github.com/w3c/web-animations/issues/201">#201</a>).
* Dropped keyframe spacing, distance calculation, and retention of invalid
keyframe property values.
* Made setting {{Animation/playbackRate}} not perform a compensatory seek
(i.e. not maintain the current time) and introduced
{{Animation/updatePlaybackRate(playbackRate)}} instead which maintains the
current time and synchronizes with animations running on another thread or
process.
* Introduced {{Animation/updatePlaybackRate(playbackRate)}} instead which
maintains the current time and synchronizes with animations running on
another thread or process.
* Added special handling to allow animating the 'offset' property from the
programming interface using <code>cssOffset</code> to avoid conflict with
the attribute name used to specify keyframe offsets.
Expand Down

0 comments on commit 673f6fc

Please sign in to comment.