Skip to content

Commit 57af558

Browse files
committed
[scroll-animations-1] Describe scroll/view-timeline-attachment
Issue 7759.
1 parent f724b31 commit 57af558

File tree

1 file changed

+131
-13
lines changed

1 file changed

+131
-13
lines changed

scroll-animations-1/Overview.bs

Lines changed: 131 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,10 @@ spec: cssom-view-1; type: dfn;
149149
(<var>[=scrollable overflow=] size</var> &minus;
150150
<var>[=scroll container=] size</var>)
151151

152-
If the 0% position and 100% position coincide
153-
(i.e. the denominator in the [=timeline/current time=] formula is zero),
154-
the timeline is [=inactive timeline|inactive=].
152+
The timeline is [=inactive timeline|inactive=] when:
153+
- The 0% position and 100% position coincide
154+
(i.e. the denominator in the [=timeline/current time=] formula is zero), or
155+
- The timeline has no [=current attachment=].
155156

156157
## Anonymous Scroll Progress Timelines ## {#scroll-timelines-anonymous}
157158

@@ -353,18 +354,105 @@ spec: cssom-view-1; type: dfn;
353354

354355
Values are as defined for ''scroll()''.
355356

357+
The [=used value=] of 'scroll-timeline-axis'
358+
is the axis of the [=current attachment=],
359+
or the initial value if there is no [=current attachment=].
360+
361+
### Attachment of a Scroll Progress Timeline: the 'scroll-timeline-attachment' property ### {#scroll-timeline-attachment}
362+
363+
<pre class='propdef'>
364+
Name: scroll-timeline-attachment
365+
Value: [ local | defer | ancestor ]#
366+
Initial: local
367+
Applies to: all elements
368+
Inherited: no
369+
Computed value: a list of the keywords specified
370+
Animation type: not animatable
371+
</pre>
372+
373+
Specifies attachment behavior for each [=scroll progress timeline=]
374+
associated with this element.
375+
376+
A scroll timeline has a set of <dfn>attachments</dfn>,
377+
that determine which [=scroll container=] and {{ScrollTimeline/axis}} to use
378+
when calculating the [progress of the timeline](#scroll-timeline-progress).
379+
380+
<dl>
381+
<dt><dfn>'local'</dfn>
382+
<dd>
383+
The [=attachments=] of the timeline is a single item set
384+
containing that timeline.
385+
386+
<dt><dfn>'defer'</dfn>
387+
<dd>
388+
The [=attachments=] is the set of timelines in the flat-tree descendants
389+
that satisfy all of the following:
390+
- The timeline has a matching 'scroll-timeline-name'.
391+
- The timeline has [=ancestor=] attachment.
392+
- The timeline has no intermediate [=defer|deferred=] timeline
393+
that would capture it.
394+
395+
<dt><dfn>'ancestor'</dfn>
396+
<dd>
397+
The set of [=attachments=] is empty.
398+
399+
Timelines with [=ancestor=] attachment are treated as nameless
400+
for the purposes of timeline lookup;
401+
they can't be referenced by 'animation-timeline'.
402+
</dl>
403+
404+
The <dfn>current attachment</dfn> of a timeline is determined as follows:
405+
406+
<dl class="switch">
407+
: If the set of [=attachments=] contains exactly one timeline
408+
:: The [=current attachment=] is that timeline.
409+
410+
: Otherwise,
411+
:: There is no [=current attachment=].
412+
</dl>
413+
414+
<div class=example>
415+
Using a [=defer|deferred timeline=],
416+
an element can effectively refer to timelines
417+
that appear <em>after it</em> in tree order.
418+
For example, the following creates an animation on <code>#target</code> that
419+
is ultimately linked to a scroll timeline defined on the subsequent sibling.
420+
421+
<pre class=lang-css>
422+
@keyframes anim {
423+
from { color: red; }
424+
to { color: green; }
425+
}
426+
427+
#root {
428+
scroll-timeline-name: mytimeline;
429+
scroll-timeline-attachment: defer;
430+
}
431+
432+
#root #target {
433+
animation: anim auto;
434+
animation-timeline: mytimeline;
435+
}
436+
437+
#root #target + #scroller {
438+
scroll-timeline-name: mytimeline;
439+
scroll-timeline-attachment: ancestor;
440+
}
441+
</pre>
442+
</div>
443+
356444
### Scroll Timeline Shorthand: the 'scroll-timeline' shorthand ### {#scroll-timeline-shorthand}
357445

358446
<pre class='propdef shorthand'>
359447
Name: scroll-timeline
360-
Value: [ <<'scroll-timeline-name'>> <<'scroll-timeline-axis'>>? ]#
448+
Value: [ <<'scroll-timeline-name'>> [ <<'scroll-timeline-axis'>> || <<'scroll-timeline-attachment'>> ]? ]#
361449
Applies to: [=scroll containers=]
362450
Inherited: no
363451
Animation type: not animatable
364452
</pre>
365453

366454
This property is a [=shorthand=] for setting
367-
'scroll-timeline-name' and 'scroll-timeline-axis'
455+
'scroll-timeline-name', 'scroll-timeline-axis' and 'scroll-timeline-attachment'
368456
in a single declaration.
369457

370458
# View Progress Timelines # {#view-timelines}
@@ -496,9 +584,10 @@ spec: cssom-view-1; type: dfn;
496584
the [=scroll offset=] corresponding to
497585
the end of the ''animation-timeline-range/cover'' range
498586

499-
If the 0% position and 100% position coincide
500-
(i.e. the denominator in the [=timeline/current time=] formula is zero),
501-
the timeline is [=inactive timeline|inactive=].
587+
The timeline is [=inactive timeline|inactive=] when:
588+
- The 0% position and 100% position coincide
589+
(i.e. the denominator in the [=timeline/current time=] formula is zero), or
590+
- The timeline has no [=current attachment=].
502591

503592
## Anonymous View Progress Timelines ## {#view-timelines-anonymous}
504593

@@ -662,6 +751,10 @@ spec: cssom-view-1; type: dfn;
662751
Specifies an axis for each named [=view progress timeline=]
663752
associated with this [=scroll container=].
664753

754+
The [=used value=] of 'view-timeline-axis'
755+
is the axis of the [=current attachment=],
756+
or the initial value if there is no [=current attachment=].
757+
665758
### Inset of a View Progress Timeline: the 'view-timeline-inset' property ### {#view-timeline-inset}
666759

667760
<pre class='propdef'>
@@ -695,18 +788,43 @@ spec: cssom-view-1; type: dfn;
695788
defines an inward offset from the corresponding edge of the scrollport.
696789
</dl>
697790

791+
The [=used value=] of 'view-timeline-inset'
792+
is the inset of the [=current attachment=],
793+
or the initial value if there is no [=current attachment=].
794+
795+
### Attachment of a View Progress Timeline: the 'view-timeline-attachment' property ### {#view-timeline-attachment}
796+
797+
<pre class='propdef'>
798+
Name: view-timeline-attachment
799+
Value: [ local | defer | ancestor ]#
800+
Initial: local
801+
Applies to: all elements
802+
Inherited: no
803+
Computed value: a list of the keywords specified
804+
Animation type: not animatable
805+
</pre>
806+
807+
Specifies attachment behavior for each [=view progress timeline=]
808+
associated with this element.
809+
810+
The behavior of 'view-timeline-attachment'
811+
is similar to that of 'scroll-timeline-attachment',
812+
except that the [=attachments=] of a view timeline also determine
813+
the <a property lt="view-timeline-inset">inset</a>
814+
and {{ViewTimeline/subject}} to use
815+
when calculating the [progress of the timeline](#view-timeline-progress).
816+
698817
### View Timeline Shorthand: the 'view-timeline' shorthand ### {#view-timeline-shorthand}
699818

700819
<pre class='propdef shorthand'>
701820
Name: view-timeline
702-
Value: [ <<'view-timeline-name'>> <<'view-timeline-axis'>>? ]#
821+
Value: [ <<'view-timeline-name'>> [ <<'view-timeline-axis'>> || <<'view-timeline-attachment'>> ]? ]#
703822
Applies to: all elements
704823
</pre>
705824

706825
This property is a [=shorthand=] for setting
707-
'view-timeline-name' and 'view-timeline-axis'
708-
in a single declaration.
709-
It does not set 'view-timeline-inset'.
826+
'view-timeline-name', 'view-timeline-axis' and 'view-timeline-attachment'
827+
in a single declaration. It does not set 'view-timeline-inset'.
710828

711829
ISSUE: Should it reset 'view-timeline-inset' also?
712830

@@ -776,7 +894,7 @@ spec: cssom-view-1; type: dfn;
776894
In case of a name conflict on the same element,
777895
[=scroll progress timelines=] take precedence over [=view progress timelines=].
778896

779-
ISSUE(7759): We plan to add functionality to expand the scope.
897+
Note: [=defer|Deferred timelines=] effectively allow scoping beyond this.
780898

781899
## Animation Events ## {#events}
782900

0 commit comments

Comments
 (0)