Skip to content
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-2] Specify Animation progress API #9937

Merged
merged 3 commits into from
Feb 29, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion web-animations-2/Overview.bs
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,9 @@ Append:
> * Set [=iteration duration=] = [=intrinsic iteration duration=]
> Otherwise:
> * Set [=iteration duration=] = |specified iteration duration|
>
> An animation's <dfn export for=animation>progress</dfn> is the ratio of its
> [=animation/current time=] to its associated effect's [=end time=].
DavMila marked this conversation as resolved.
Show resolved Hide resolved

### Setting the timeline of an animation ### {#setting-the-timeline}

Expand Down Expand Up @@ -969,6 +972,30 @@ Add the following sentence:

</div>

### Calculating the progress of an animation ### {#the-progress-of-an-animation}

The [=animation/progress=] of an [=animation=] is calculated as follows:
DavMila marked this conversation as resolved.
Show resolved Hide resolved

<dl class=switch>

: If <em>any</em> of the following are true:
* the animation does not have an [=animation/associated effect=], or
* the animation's associated effect's [=end time=] is infinite, or
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the thinking behind making infinite → null as opposed to zero? I think zero might be more useful overall since it represents where the animation is actually up to.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took @flackr 's point about distinguishing between 0 due to infinite duration and 0 that can actually make progress into consideration. But yes, 0 is probably more accurate. I'll write that in the algorithm.

* the animation's associated effect's [=end time=] is zero, or
DavMila marked this conversation as resolved.
Show resolved Hide resolved
* the animation's [=animation/current time=] time is an [=unresolved=] time value,
::
The animation's [=animation/progress=] is null.
: Otherwise,
::
<blockquote>
<code><a for="animation">progress</a> = [=animation/current time=] / <var>effect end time</var>
</code>
</blockquote>

Where |effect end time| is the current [=end time=] of the associated effect.
DavMila marked this conversation as resolved.
Show resolved Hide resolved

</dl>


<h3 id="animation-effects">Animation effects</h3>

Expand Down Expand Up @@ -2390,7 +2417,7 @@ Update the attribute type for currentTime.
<h3 id="the-animation-interface">The <code>Animation</code> interface</h3>

Update the startTime and currentTime of the Animation interface, and add
rangeStart and rangeEnd as follows:
rangeStart, rangeEnd, and progress as follows:

<pre class="idl">
[Exposed=Window]
Expand All @@ -2399,6 +2426,7 @@ partial interface Animation {
attribute CSSNumberish? currentTime;
attribute (TimelineRangeOffset or CSSNumericValue or CSSKeywordValue or DOMString) rangeStart;
attribute (TimelineRangeOffset or CSSNumericValue or CSSKeywordValue or DOMString) rangeEnd;
readonly attribute double? progress;
};
</pre>

Expand Down Expand Up @@ -2443,6 +2471,10 @@ Add:
> <a href="#dom-keyframeanimationoptions-rangeend">rangeEnd</a>.
> When reading the attribute, the returned value is either a
> {{TimelineRangeOffset}} or the {{DOMString}} "normal".
>
> : <dfn attribute for=Animation>progress</dfn>
> :: Specifies the progress of the <a>animation</a> as a proportion of its
> [=animation/associated effect=]'s [=end time=].
DavMila marked this conversation as resolved.
Show resolved Hide resolved
</div>

<h3 id="the-animationeffect-interface">The <code>AnimationEffect</code> interface</h3>
Expand Down