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 all commits
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
42 changes: 41 additions & 1 deletion web-animations-2/Overview.bs
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,41 @@ Add the following sentence:

</div>

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

An animation's <dfn export for=animation>progress</dfn> is the ratio of its
[=animation/current time=] to its [=associated effect end=].

<div algorithm="calculate animation progress">
The [=animation/progress=] of an [=animation=], |animation|, is calculated as follows:

<dl class=switch>

: If <em>any</em> of the following are true:
* |animation| does not have an [=animation/associated effect=], or
* |animation|'s [=animation/current time=] is an [=unresolved=] time value,
::
|animation|'s [=animation/progress=] is null.
: If |animation|'s [=associated effect end=] is zero,
::
: If |animation|'s [=animation/current time=] is negative,
:: |animation|'s [=animation/progress=] is zero.

: Otherwise,
:: |animation|'s [=animation/progress=] is one.
: If |animation|'s [=associated effect end=] is infinite,
::
|animation|'s [=animation/progress=] is zero.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can the author tell if we're active (after the start time) or inactive (before the start time)?

: Otherwise,
::
<blockquote>
<code><a for="animation">progress</a> = min(max([=animation/current time=] / |animation|'s [=associated effect end=], 0), 1)
</code>
</blockquote>

</dl>
</div>


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

Expand Down Expand Up @@ -2390,7 +2425,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 +2434,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 +2479,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 [=animation/progress=] of the <a>animation</a> as a proportion of its
> [=associated effect end=].
</div>

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