From 711163d9cf2bcfcf6bccdfbfdf23dcf52e07f652 Mon Sep 17 00:00:00 2001 From: David Awogbemila Date: Mon, 12 Feb 2024 16:15:06 -0500 Subject: [PATCH 1/3] [web-animations-2] Specify Animation progress API --- web-animations-2/Overview.bs | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/web-animations-2/Overview.bs b/web-animations-2/Overview.bs index 5c5863c73d5..3cbc6972f26 100644 --- a/web-animations-2/Overview.bs +++ b/web-animations-2/Overview.bs @@ -262,6 +262,9 @@ Append: > * Set [=iteration duration=] = [=intrinsic iteration duration=] > Otherwise: > * Set [=iteration duration=] = |specified iteration duration| +> +> An animation's progress is the ratio of its +> [=animation/current time=] to its associated effect's [=end time=]. ### Setting the timeline of an animation ### {#setting-the-timeline} @@ -969,6 +972,30 @@ Add the following sentence: +### Calculating the progress of an animation ### {#the-progress-of-an-animation} + + The [=animation/progress=] of an [=animation=] is calculated as follows: + +
+ + : If any 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 + * the animation's associated effect's [=end time=] is zero, or + * the animation's [=animation/current time=] time is an [=unresolved=] time value, + :: + The animation's [=animation/progress=] is null. + : Otherwise, + :: +
+ progress = [=animation/current time=] / effect end time + +
+ + Where |effect end time| is the current [=end time=] of the associated effect. + +
+

Animation effects

@@ -2390,7 +2417,7 @@ Update the attribute type for currentTime.

The Animation interface

Update the startTime and currentTime of the Animation interface, and add -rangeStart and rangeEnd as follows: +rangeStart, rangeEnd, and progress as follows:
 [Exposed=Window]
@@ -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;
 };
 
@@ -2443,6 +2471,10 @@ Add: > rangeEnd. > When reading the attribute, the returned value is either a > {{TimelineRangeOffset}} or the {{DOMString}} "normal". +> +> : progress +> :: Specifies the progress of the animation as a proportion of its +> [=animation/associated effect=]'s [=end time=].

The AnimationEffect interface

From 85ccce9f94ef459aa5e55391625cbe4becfa6ef6 Mon Sep 17 00:00:00 2001 From: David Awogbemila Date: Tue, 13 Feb 2024 13:58:40 -0500 Subject: [PATCH 2/3] Link progress to algorithm and make infinite duration progres zero --- web-animations-2/Overview.bs | 45 ++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/web-animations-2/Overview.bs b/web-animations-2/Overview.bs index 3cbc6972f26..47b3ab73450 100644 --- a/web-animations-2/Overview.bs +++ b/web-animations-2/Overview.bs @@ -262,9 +262,6 @@ Append: > * Set [=iteration duration=] = [=intrinsic iteration duration=] > Otherwise: > * Set [=iteration duration=] = |specified iteration duration| -> -> An animation's progress is the ratio of its -> [=animation/current time=] to its associated effect's [=end time=]. ### Setting the timeline of an animation ### {#setting-the-timeline} @@ -974,27 +971,31 @@ Add the following sentence: ### Calculating the progress of an animation ### {#the-progress-of-an-animation} - The [=animation/progress=] of an [=animation=] is calculated as follows: + An animation's progress is the ratio of its + [=animation/current time=] to its [=associated effect end=]. -
+
+ The [=animation/progress=] of an [=animation=], |animation|, is calculated as follows: - : If any 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 - * the animation's associated effect's [=end time=] is zero, or - * the animation's [=animation/current time=] time is an [=unresolved=] time value, - :: - The animation's [=animation/progress=] is null. - : Otherwise, - :: -
- progress = [=animation/current time=] / effect end time - -
+
- Where |effect end time| is the current [=end time=] of the associated effect. + : If any of the following are true: + * |animation| does not have an [=animation/associated effect=], or + * |animation|'s [=associated effect end=] is zero, or + * |animation|'s [=animation/current time=] is an [=unresolved=] time value, + :: + |animation|'s [=animation/progress=] is null. + : If |animation|'s [=associated effect end=] is infinite, + |animation|'s [=animation/progress=] is zero. + : Otherwise, + :: +
+ progress = [=animation/current time=] / |animation|'s [=associated effect end=] + +
-
+
+

Animation effects

@@ -2473,8 +2474,8 @@ Add: > {{TimelineRangeOffset}} or the {{DOMString}} "normal". > > : progress -> :: Specifies the progress of the animation as a proportion of its -> [=animation/associated effect=]'s [=end time=]. +> :: Specifies the [=animation/progress=] of the animation as a proportion of its +> [=associated effect end=].

The AnimationEffect interface

From d89d8b8c7ca7082f228b795fc8cef195126ec3df Mon Sep 17 00:00:00 2001 From: David Awogbemila Date: Wed, 21 Feb 2024 14:46:30 -0500 Subject: [PATCH 3/3] [web-animations-2] Specify Animation progress API -Clamp progress to [0,1]. -Zero duration depends on nonegativity of currentTime. --- web-animations-2/Overview.bs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/web-animations-2/Overview.bs b/web-animations-2/Overview.bs index 47b3ab73450..72168a59047 100644 --- a/web-animations-2/Overview.bs +++ b/web-animations-2/Overview.bs @@ -981,16 +981,23 @@ Add the following sentence: : If any of the following are true: * |animation| does not have an [=animation/associated effect=], or - * |animation|'s [=associated effect end=] is zero, 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. : Otherwise, ::
- progress = [=animation/current time=] / |animation|'s [=associated effect end=] + progress = min(max([=animation/current time=] / |animation|'s [=associated effect end=], 0), 1)