Skip to content

Commit 4cf807e

Browse files
committed
[scroll-animations-1] Define current time of scroll-driven timelines. w3c#7778
1 parent 5e2138c commit 4cf807e

1 file changed

Lines changed: 35 additions & 4 deletions

File tree

scroll-animations-1/Overview.bs

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ spec:web-animations-1;
3131
type:interface; text:AnimationTimeline
3232
type:attribute; text:currentTime
3333
type:dfn;
34+
text:current time
3435
text:active interval
3536
text:start delay
3637
text:end delay
@@ -128,9 +129,6 @@ spec: cssom-view-1; type: dfn;
128129
along a particular axis.
129130
The startmost scroll position represents 0% progress
130131
and the endmost scroll position represents 100% progress.
131-
If the 0% position and 100% position coincide
132-
(i.e. the [=scroll container=] has no overflow to scroll),
133-
the timeline is [=inactive timeline|inactive=].
134132

135133
[=Scroll progress timelines=] can be referenced in 'animation-timeline'
136134
anonymously using the ''scroll()'' [=functional notation=]
@@ -139,6 +137,18 @@ spec: cssom-view-1; type: dfn;
139137
In the Web Animations API,
140138
they can be represented anonymously by a {{ScrollTimeline}} object.
141139

140+
## Calculating Progress for a Scroll Progress Timeline ## {#scroll-timeline-progress}
141+
142+
Progress (the [=current time=]) for a [=scroll progress timeline=]
143+
is calculated as:
144+
<var>[=scroll offset=]</var> &div;
145+
(<var>[=scrollable overflow=] size</var> &minus;
146+
<var>[=scroll container=] size</var>)
147+
148+
If the 0% position and 100% position coincide
149+
(i.e. the denominator in the [=current time=] formula is zero),
150+
the timeline is [=inactive timeline|inactive=].
151+
142152
## Anonymous Scroll Progress Timelines ## {#scroll-timelines-anonymous}
143153

144154
### The ''scroll()'' notation ### {#scroll-notation}
@@ -368,7 +378,8 @@ spec: cssom-view-1; type: dfn;
368378
(or more precisely, the relevant [=view progress visibility range=]
369379
of that [=scrollport=]).
370380
The startmost such scroll position represents 0% progress
371-
and the endmost such scroll position represents 100% progress.
381+
and the endmost such scroll position represents 100% progress,
382+
see [[#view-timeline-progress]].
372383

373384
Note: The 0% and 100% scroll positions are not always reachable,
374385
e.g. if the box is positioned
@@ -465,6 +476,26 @@ spec: cssom-view-1; type: dfn;
465476
is used when identifying 100% progress.
466477
[[CSS-POSITION-3]] [[CSS-TRANSFORMS-1]]
467478

479+
## Calculating Progress for a View Progress Timeline ## {#view-timeline-progress}
480+
481+
Progress (the [=current time=]) in a [=view progress timeline=]
482+
is calculated as:
483+
|distance| &div; |range|
484+
where:
485+
* |distance| is the current [=scroll offset=]
486+
minus the [=scroll offset=] corresponding to
487+
the start of the ''animation-timeline-range/cover'' range
488+
* |range| is
489+
the [=scroll offset=] corresponding to
490+
the start of the ''animation-timeline-range/cover'' range
491+
minus
492+
the [=scroll offset=] corresponding to
493+
the end of the ''animation-timeline-range/cover'' range
494+
495+
If the 0% position and 100% position coincide
496+
(i.e. the denominator in the [=current time=] formula is zero),
497+
the timeline is [=inactive timeline|inactive=].
498+
468499
## Anonymous View Progress Timelines ## {#view-timelines-anonymous}
469500

470501
### The ''view()'' notation ### {#view-notation}

0 commit comments

Comments
 (0)