Skip to content

Commit 048d212

Browse files
Kevin Ellisbirtles
authored andcommitted
rebase
1 parent 9ae05b8 commit 048d212

2 files changed

Lines changed: 99 additions & 88 deletions

File tree

scroll-animations-1/Overview.bs

Lines changed: 11 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ Using the CSS markup:
140140
<pre class='lang-css'>
141141
@media (prefers-reduced-motion: no-preference) {
142142
div.circle {
143-
animation-duration: 1s;
144143
animation-timing-function: linear;
145144
animation-timeline: collision-timeline;
146145
}
@@ -191,13 +190,13 @@ if (window.matchMedia('(prefers-reduced-motion: no-preference)').matches) {
191190
scrollOffsets: [CSS.px(200), CSS.px(300)]
192191
});
193192

194-
const left = leftCircle.animate({ transform: 'translate(300px)' }, 1000);
193+
const left = leftCircle.animate({ transform: 'translate(300px)' });
195194
left.timeline = collisionTimeline;
196195

197-
const right = leftCircle.animate({ transform: 'translate(350px)' }, 1000);
196+
const right = leftCircle.animate({ transform: 'translate(350px)' });
198197
right.timeline = collisionTimeline;
199198

200-
const union = unionCircle.animate({ opacity: 1 }, { duration: 1000, fill: "forwards" });
199+
const union = unionCircle.animate({ opacity: 1 }, { fill: "forwards" });
201200
union.timeline = new ScrollTimeline({
202201
source: scrollableElement,
203202
scrollOffsets: [CSS.px(250), CSS.px(300)]
@@ -253,7 +252,7 @@ If we use this API for this case, the example code will be as follow:
253252

254253
<pre class='lang-javascript'>
255254
if (window.matchMedia('(prefers-reduced-motion: no-preference)').matches) {
256-
var animation = div.animate({ width: '100%' }, { duration: 1000, fill: "forwards" });
255+
var animation = div.animate({ width: '100%' }, { fill: "forwards" });
257256
animation.timeline = new ScrollTimeline(
258257
{
259258
scrollOffsets: [0, CSS.percent(100)]
@@ -360,7 +359,6 @@ dictionary ScrollTimelineOptions {
360359
Element? source;
361360
ScrollDirection orientation = "block";
362361
sequence&lt;ScrollTimelineOffset&gt; scrollOffsets = [];
363-
(double or ScrollTimelineAutoKeyword) timeRange = "auto";
364362
};
365363

366364
[Exposed=Window]
@@ -369,14 +367,15 @@ interface ScrollTimeline : AnimationTimeline {
369367
readonly attribute Element? source;
370368
readonly attribute ScrollDirection orientation;
371369
readonly attribute FrozenArray&lt;ScrollTimelineOffset&gt; scrollOffsets;
372-
readonly attribute (double or ScrollTimelineAutoKeyword) timeRange;
373370
};
374371
</pre>
375372

376373
A <dfn>scroll timeline</dfn> is an {{AnimationTimeline}} whose time values are
377374
determined not by wall-clock time, but by the progress of scrolling in a
378375
[=scroll container=].
379376

377+
The {{AnimationTimeline/Duration}} of a <a>scroll timeline</a> is 100%.
378+
380379
<div link-for-hint="ScrollTimeline">
381380

382381
<div class="constructors">
@@ -403,10 +402,9 @@ determined not by wall-clock time, but by the progress of scrolling in a
403402

404403
1. Set the {{ScrollTimeline/source}} of |timeline| to |source|.
405404

406-
1. Assign the {{ScrollTimeline/orientation}}, {{ScrollTimeline/scrollOffsets}}
407-
and {{ScrollTimeline/timeRange}} properties of
405+
1. Assign the {{ScrollTimeline/orientation}} and
406+
{{ScrollTimeline/scrollOffsets}} properties of
408407
|timeline| to the corresponding value from |options|.
409-
410408
</div>
411409

412410
<div class="attributes">
@@ -453,25 +451,6 @@ determined not by wall-clock time, but by the progress of scrolling in a
453451

454452
</div>
455453

456-
: <dfn attribute for=ScrollTimeline>timeRange</dfn>
457-
:: A time duration that allows mapping between a distance scrolled, and
458-
quantities specified in time units, such as an animation's [=duration=] and
459-
[=start delay=].
460-
461-
Conceptually, {{timeRange}} represents the number of milliseconds to map to
462-
the scroll range defined by {{start}} and {{end}}. As a result, this value
463-
does not have a correspondence to wall-clock time.
464-
465-
This value is used to compute the timeline's [=effective time range=], and
466-
the mapping is then defined by mapping the scroll distance from
467-
{{start}} to {{end}}, to the [=effective time range=].
468-
469-
Issue(4862): We are working to remove the need for {{timeRange}} to be declared.
470-
The most recent work on this involved introduction of the concept of
471-
"progress-based animations" to web animations.
472-
473-
</div>
474-
475454
### Scroll Timeline Offset ### {#scroll-timeline-offset-section}
476455

477456
An <dfn>effective scroll offset</dfn> is a scroll position for a given [=scroll
@@ -711,8 +690,7 @@ if (window.matchMedia('(prefers-reduced-motion: no-preference)').matches) {
711690
transform: ['translateX(0)', 'translateX(50vw)'],
712691
opacity: [0, 1]
713692
}, {
714-
timeline:timeline,
715-
duration: 1000
693+
timeline:timeline
716694
}
717695
);
718696
}
@@ -741,36 +719,12 @@ The same logic can be done in CSS markup:
741719

742720
#target {
743721
animation-name: slide-in;
744-
animation-duration: 1s;
745722
animation-timeline: image-in-scrollport;
746723
}
747724

748725
}
749726
</pre>
750727

751-
752-
</div>
753-
754-
### The effective time range of a {{ScrollTimeline}} ### {#effective-time-range-algorithm}
755-
756-
The <dfn>effective time range</dfn> of a {{ScrollTimeline}} is calculated as
757-
follows:
758-
759-
<div class="switch">
760-
761-
: If the {{timeRange}} has the value `"auto"`,
762-
:: The [=effective time range=] is the maximum value of the
763-
[=target effect end=] of all animations
764-
directly associated with this timeline.
765-
766-
If any animation directly associated with the timeline has a
767-
[=target effect end=] of infinity, the [=effective time range=]
768-
is zero.
769-
770-
: Otherwise,
771-
:: The [=effective time range=] is the {{ScrollTimeline}}'s
772-
{{timeRange}}.
773-
774728
</div>
775729

776730
### The effective scroll offsets of a {{ScrollTimeline}} ### {#effective-scroll-offsets-algorithm}
@@ -910,15 +864,15 @@ The [=current time=] of a {{ScrollTimeline}} is calculated as follows:
910864

911865
: If |current scroll offset| is greater than or equal to [=effective
912866
end offset=]:
913-
:: The [=current time=] is the [=effective time range=].
867+
:: The [=current time=] is the [=duration=].
914868

915869
: Otherwise,
916870
:: 1. Let |progress| be a result of applying
917871
[=calculate scroll timeline progress=] procedure for <var>current scroll offset</var>.
918872
1. The [=current time=] is the result of evaluating the following expression:
919873

920874
<blockquote>
921-
<code>|progress| &times; [=effective time range=]</code>
875+
<code>|progress| &times; [=duration=]</code>
922876
</blockquote>
923877

924878
</div>
@@ -1032,17 +986,6 @@ following:
1032986
* {{ElementBasedOffset/threshold}} is the optional value <<number>>. If
1033987
not provided it defaults to 0.
1034988

1035-
</div>
1036-
1037-
<pre class='descdef'>
1038-
Name: time-range
1039-
For: @scroll-timeline
1040-
Value: auto | <<time>>
1041-
Initial: auto
1042-
</pre>
1043-
1044-
'time-range' descriptor determines the scroll timeline's {{timeRange}}.
1045-
1046989
</div> <!-- link-for-hint="ScrollTimeline" -->
1047990

1048991
### The <dfn interface>CSSScrollTimelineRule</dfn> Interface ### {#the-css-scroll-timeline-rule-interface}
@@ -1054,7 +997,6 @@ interface CSSScrollTimelineRule : CSSRule {
1054997
readonly attribute CSSOMString source;
1055998
readonly attribute CSSOMString orientation;
1056999
readonly attribute CSSOMString scrollOffsets;
1057-
readonly attribute CSSOMString timeRange;
10581000
};
10591001
</pre>
10601002

@@ -1079,11 +1021,6 @@ interface CSSScrollTimelineRule : CSSRule {
10791021
<dd>
10801022
The 'scroll-offsets' descriptor associated with the ''@scroll-timeline'', or "none" if not specified.
10811023
</dd>
1082-
1083-
<dt><dfn>timeRange</dfn></dt>
1084-
<dd>
1085-
The 'time-range' descriptor associated with the ''@scroll-timeline'', or "auto" if not specified.
1086-
</dd>
10871024
</dl>
10881025

10891026
<div algorithm>
@@ -1212,7 +1149,6 @@ interface CSSScrollTimelineRule : CSSRule {
12121149
{ width: "100vw" }
12131150
],
12141151
{
1215-
duration: 1000,
12161152
easing: "linear",
12171153
fill: "forwards"
12181154
});
@@ -1255,7 +1191,6 @@ interface CSSScrollTimelineRule : CSSRule {
12551191
/* This name is used to select both the keyframes and the
12561192
scroll-timeline at-rules. */
12571193
animation-name: progress;
1258-
animation-duration: 1s;
12591194
animation-fill-mode: forwards;
12601195
animation-timing-function: linear;
12611196
}

web-animations-2/Overview.bs

Lines changed: 88 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,48 @@ Along with the following updated description:
144144
</div>
145145

146146

147+
<h3 id="timelines">Timelines</h3>
148+
149+
Add:
150+
151+
> The <dfn lt="timeline duration">duration</dfn> of a timeline gives the
152+
> maximum value a timeline may generate for its current time. This value is
153+
> used to calculate the [=intrinsic iteration duration=] for the target effect
154+
> of an animation that is associated with the timeline when the effect's
155+
> [=iteration duration=] is 'auto'. The value is computed such that the effect
156+
> fills the available time. For a monotonic timeline, there is no upper bound
157+
> on current time, and [=timeline duration=] is unresolved. For a progress based
158+
> timeline, the [=timeline duration=] is 100%.
159+
147160
<h3 id="animations">Animations</h3>
148161

149-
<div class="informative-bg"><em>This section is non-normative</em>
162+
Add:
163+
164+
> Animation effects associated with a progress-based timeline require their
165+
> timing properties to be converted to proportions. The procedure for converting
166+
> a <dfn lt="time-based animation to a proportional animation"></dnf> is as
167+
> follows:
168+
>
169+
> 1. If the [=iteration duration=] is auto, then perform the following steps.
170+
>
171+
> 1. Compute [=start delay=] and [=end delay=] to 0, as it is not possible
172+
> to mix time and proportions. Future versions may allow these properties
173+
> to be assigned percentages.
174+
>
175+
> 1. Otherwise,
176+
>
177+
> 1. Let <var>total time</var> be equal to the result of evaluating
178+
> <code>|start delay| + |iteration count| * |iteration duration| +
179+
> |end delay|</code>.
180+
>
181+
> 1. Compute [=start delay=] to be the result of evaluating
182+
> <code>|start delay| / |total time| * |timeline duration|</code>.
183+
>
184+
> 1. Compute [=iteration duration=] to be the result of evaluating
185+
> <code>|iteration duration| / |total time| * |timeline duration|</code>.
186+
>
187+
> 1. Compute [=end delay=] to be the result of evaluating
188+
> <code>|end delay| / |total time| * |timeline duration|</code>.
150189
151190
<h4 id="setting-the-timeline">Setting the timeline of an animation</h4>
152191
@@ -944,13 +983,24 @@ Add:
944983

945984
> The initial <a>iteration duration</a> of an animation effect is simply its
946985
> <a>intrinsic iteration duration</a>.
986+
> The <dfn>intrinsic iteration duration</dfn> is calculated from the first
987+
> matching condition from below:
988+
>
989+
> <div class="switch">
990+
> : If the animation effect is a <a>group effect</a>,
991+
> :: Follow the procedure in
992+
> [[#the-intrinsic-iteration-duration-of-a-group-effect]]
947993
>
948-
> The <dfn>intrinsic iteration duration</dfn> of an animation effect is
949-
> zero, however some specific types of animation effect such as
950-
> <a>group effects</a> override this behavior and provide an
951-
> alternative intrinsic duration (see
952-
> [[#the-intrinsic-iteration-duration-of-a-group-effect]] and
953-
> [[#the-intrinsic-iteration-duration-of-a-sequence-effect]]).
994+
> : If the animation effect is a <a>sequence effect</a>,
995+
> :: Follow the procedure in
996+
> [[#the-intrinsic-iteration-duration-of-a-sequence-effect]]
997+
>
998+
> : If [=timeline duration=] is unresolved,
999+
> :: Return 0
1000+
>
1001+
> : Otherwise
1002+
> :: Return [=timeline duration=] / <a>iteration count</a>
1003+
> </div>
9541004
>
9551005
> The <a>iteration duration</a> of an <a>animation effect</a> may be set
9561006
> by the author to represent a value other than the <a>intrinsic
@@ -1886,10 +1936,18 @@ Items sorted earlier are executed before those sorted later.
18861936
<pre class="idl">
18871937
[Exposed=Window]
18881938
partial interface AnimationTimeline {
1939+
readonly attribute CSSNumberish? duration;
18891940
Animation play (optional AnimationEffect? effect = null);
18901941
};
18911942
</pre>
18921943

1944+
<div class='attributes'>
1945+
1946+
: <dfn attribute for=AnimationTimeline>duration</dfn>
1947+
:: Returns the <a lt="timeline duration">duration</a> for this timeline.
1948+
1949+
</div>
1950+
18931951
<div class='methods'>
18941952

18951953
: <dfn method for=AnimationTimeline lt='play()'>
@@ -2054,6 +2112,10 @@ partial dictionary OptionalEffectTiming {
20542112
> The <a>start delay</a> which represents the number of milliseconds from an
20552113
> <a>animation effect</a>'s <a lt="animation effect start time">start
20562114
> time</a> to the start of the <a>active interval</a>.
2115+
> If the <a lt="timeline duration">duration</dfn> of the Animation's
2116+
> <a>timeline</a> is a percentage, the start delay will be treated as the
2117+
> result of applying the procedure to convert a
2118+
> [=time-based animation to a proportional animation=].
20572119

20582120
: <dfn>endDelay</dfn>
20592121
:: Update the description as:
@@ -2063,12 +2125,21 @@ partial dictionary OptionalEffectTiming {
20632125
> until the <a lt='animation effect start time'>start time</a> of any
20642126
> <a>animation effect</a> that may
20652127
> follow, for example, in a <a>sequence effect</a>.
2128+
> If the <a lt="timeline duration">duration</dfn> of the Animation's
2129+
> <a>timeline</a> is a percentage, the end delay will be treated as the
2130+
> result of applying the procedure to convert a
2131+
> [=time-based animation to a proportional animation=].
20662132

20672133
</div>
20682134

20692135
: <dfn>duration</dfn>
20702136
:: Add:
20712137

2138+
> If the <a lt="timeline duration">duration</dfn> of the Animation's
2139+
> <a>timeline</a> is a percentage, a non <code>auto</code> duration will
2140+
> be treated as the result of applying the procedure to convert a
2141+
> [=time-based animation to a proportional animation=].
2142+
20722143
> The string value <code>auto</code> is used to indicate that the
20732144
> <a>iteration duration</a> reflects the animation effect's
20742145
> <a>intrinsic iteration duration</a>.
@@ -2086,15 +2157,20 @@ partial dictionary OptionalEffectTiming {
20862157

20872158
<pre class='idl'>
20882159
partial dictionary ComputedEffectTiming {
2089-
double startTime;
2160+
CSSNumberish startTime;
2161+
CSSNumberish endTime;
2162+
CSSNumberish activeDuration;
2163+
CSSNumberish? localTime;
2164+
CSSNumberish? progress;
20902165
};
20912166
</pre>
20922167

20932168
<div class='members'>
20942169

20952170
: <dfn dict-member for=ComputedEffectTiming>startTime</dfn>
20962171
:: The <a lt='animation effect start time'>start time</a> of this
2097-
<a>animation effect</a> in milliseconds.
2172+
<a>animation effect</a> in milliseconds or as a percentage of the
2173+
[=timeline duration=].
20982174
This is the time at which the <a>parent group</a>, if
20992175
any, has scheduled this child to run within its <a
21002176
lt="transformed time">transformed time space</a>, that is, the
@@ -2110,7 +2186,7 @@ partial dictionary ComputedEffectTiming {
21102186

21112187
> The <a>end time</a> of the <a>animation effect</a> expressed
21122188
> in milliseconds in <a lt="inherited time">inherited time
2113-
> space</a>.
2189+
> space</a> or as a percentage of the [=timeline duration=].
21142190

21152191
> This corresponds to the end of the <a>animation effect</a>'s active
21162192
> interval plus any <a>end delay</a>.
@@ -2478,8 +2554,8 @@ Replace:
24782554

24792555
with:
24802556

2481-
> If the duration is not specified, the <a>intrinsic iteration
2482-
> duration</a> is used which, for a <a>keyframe effect</a>, is zero.
2557+
> If the duration is not specified, the [=intrinsic iteration duration=] is
2558+
> used.
24832559

24842560
Add:
24852561

0 commit comments

Comments
 (0)