New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[web-animations-1] Initialize start time of scroll animations to zero (#2075) #4842
Changes from 1 commit
1fd6277
fc80ef2
3df0083
441a771
5d11616
4806500
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -828,31 +828,6 @@ follows: | |
<var>animation</var> with the <var>did seek</var> flag set to false, and | ||
the <var>synchronously notify</var> flag set to false. | ||
|
||
<h4 id="responding-to-a-newly-inactive-timeline">Responding to a newly inactive | ||
timeline</h4> | ||
|
||
Issue(2080): With the set of timelines defined in this level of this | ||
specification, this situation is not expected to occur. As | ||
a result, this section will likely be moved to a subsequent level | ||
of this specification. | ||
|
||
When the <a>timeline</a> associated with an <a>animation</a>, | ||
<var>animation</var>, becomes newly <a lt="inactive timeline">inactive</a>, | ||
if <var>animation</var>'s <a>previous current time</a> is <a | ||
lt="unresolved">resolved</a>, the procedure to <a>silently set the current | ||
time</a> of <var>animation</var> to <a>previous current time</a> is run. | ||
|
||
<div class="note"> | ||
|
||
This step makes the behavior when an <a>animation</a>'s <a>timeline</a> becomes | ||
<a lt="inactive timeline">inactive</a> consistent with when it is | ||
disassociated with a <a>timeline</a>. | ||
Furthermore, it ensures that the only occasion on which an <a>animation</a> | ||
becomes <a lt="idle play state">idle</a>, is when the procedure to | ||
<a>cancel an animation</a> is performed. | ||
|
||
</div> | ||
|
||
<h4 id="setting-the-associated-effect" oldids="setting-the-target-effect">Setting the associated effect of an animation</h4> | ||
|
||
The procedure to <dfn>set the associated effect of an animation</dfn>, | ||
|
@@ -1150,7 +1125,14 @@ as CSS Animations [[CSS-ANIMATIONS-1]]. | |
condition from the following, if any: | ||
|
||
<div class="switch"> | ||
|
||
: If |animation|'s <a>current time</a> is <a>unresolved</a>, | ||
<a>start time</a> is <a>unresolved</a>, the <var>auto-rewind</var> | ||
flag is true and <em>either</em>: | ||
* the |animation| has no associated <a>timeline</a>, or | ||
* the associated <a>timeline</a> is | ||
<a lt="inactive timeline">inactive</a> | ||
|
||
:: Set <var>animation</var>'s <a>start time</a> to zero. | ||
: If |animation|'s [=effective playback rate=] > 0, | ||
the <var>auto-rewind</var> flag is true and <em>either</em> | ||
<var>animation</var>'s: | ||
|
@@ -1185,9 +1167,10 @@ as CSS Animations [[CSS-ANIMATIONS-1]]. | |
1. Cancel that task. | ||
1. Set <var>has pending ready promise</var> to true. | ||
|
||
1. If the following three conditions are <em>all</em> satisfied: | ||
1. If the following four conditions are <em>all</em> satisfied: | ||
|
||
* |animation|'s [=hold time=] is [=unresolved=], and | ||
* |animation|'s [=start time=] is [=unresolved=], and | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not quite sure I follow this but I think it probably relates back to my comment here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is required to avoid early exit if start time is set. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure about this. Won't this mean that calling There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could probably fix the above by simply adding some extra flag to this procedure to indicate if we made a change that means that we need to wait for a pending task to run. This might be a more elegant way, however. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added the flag. |
||
* |aborted pause| is false, and | ||
* |animation| does <em>not</em> have a [=pending playback rate=], | ||
|
||
|
@@ -1324,6 +1307,12 @@ follows: | |
perform the steps according to the first matching condition from below: | ||
|
||
<div class="switch"> | ||
: If |animation|'s <a>start time</a> is <a>unresolved</a> and | ||
<em>either</em>: | ||
* the |animation| has no associated <a>timeline</a>, or | ||
* the associated <a>timeline</a> is | ||
<a lt="inactive timeline">inactive</a> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As with my first comment, I'm afraid I don't follow why we have these particular conditions. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The explanation is the same as in the first comment. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please see the first comment. |
||
:: Let <var>animation</var>'s <a>start time</a> be zero. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (Presumably whatever we decide for the play procedure will also apply here.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed similarly to Play. |
||
|
||
: If <var>animation</var>'s [=playback rate=] is ≥ 0, | ||
:: Let <var>animation</var>'s <a>hold time</a> be zero. | ||
|
@@ -1345,10 +1334,14 @@ follows: | |
1. If <var>has pending ready promise</var> is false, | ||
set <var>animation</var>'s <a>current ready promise</a> to | ||
<a>a new promise</a> in the <a>relevant Realm</a> of <var>animation</var>. | ||
1. Schedule a task to be executed at the first possible moment after | ||
the user agent has performed any processing necessary to suspend | ||
the playback of | ||
<var>animation</var>'s <a>associated effect</a>, if any. | ||
1. Schedule a task to be executed at the first possible moment where | ||
<em>both</em> of the following conditions are true: | ||
* the user agent has performed any processing necessary to suspend | ||
the playback of <var>animation</var>'s <a>associated effect</a>, if any. | ||
|
||
* the animation is associated with a <a>timeline</a> that is not | ||
<a lt="inactive timeline">inactive</a>. | ||
|
||
The task shall perform the following steps: | ||
|
||
1. Let <var>ready time</var> be the time value of the timeline associated | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm afraid I don't quite understand the reasoning behind these conditions. I thought we discussed setting the start time to zero for scroll-based timelines? But they won't necessarily have no timeline, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting start time to zero and hold time to null produces unresolved current time. This is to ensure no animation effect is applied when the timeline is inactive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to be clear regarding your comment about zero start time initialization for scroll timeline, I am planning to make this change later, but as part of a separate PR. The goal of this PR is just handling inactive/null timelines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. So the tricky part is making an inactive timeline produce an unresolved current time in the animation whilst also still allowing animations without a timeline to be seeked to a particular time.
This is complicated because we might have Web compat issues here given that Chrome and Firefox both ship the
Animation()
constructor so the behavior of callingplay()
on animations without a timeline is already observable.That said, we probably don't commonly encounter inactive timelines, so I wonder if we can make this change simply apply to inactive timelines?
Or is it a bit odd that calling
play()
on an animation without a timeline behaves differently from callingplay()
on an animation attached to an inactive timeline? From my understanding, both would make the animation "running" and pending, but in the first case thecurrentTime
would be zero, but in the second case thecurrentTime
would benull
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With #4899 proposal, if accepted, play/pause procedures will be updated to initialize start time to zero for both active and inactive finite timelines. Event without #4899, we probably should be initializing start time to 0 for finite timeline linked animations regardless of the timeline activeness.
Having said this, we need to decide which behavior we expect from animations without a timeline. In #2066 the "half" agreement was to treat a null timeline as inactive timeline, meaning animations don't expose animation effect. If this indeed the desired behavior, perhaps we can find a way to phaseout already shipped behavior in favor of the desired one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to initialize start time of finite timeline animations to 0. No changes are made for the animations that don't have a timeline. Note, in this change we initialize start time to 0 regardless of the timeline activeness. It achieves the desired effect when the timeline is active (anim.currentTime==timeline.currentTime) and when the timeline is inactive (animation.currentTime = null).