Skip to content

Commit 5fd2d9d

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

File tree

1 file changed

+143
-13
lines changed

1 file changed

+143
-13
lines changed

scroll-animations-1/Overview.bs

Lines changed: 143 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,20 +354,113 @@ 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' and either 'scroll-timeline-axis' or 'scroll-timeline-axis'
368456
in a single declaration.
369457

458+
If the 'scroll-timeline-axis' property is omitted,
459+
it is set to its [=initial value=].
460+
461+
If the 'scroll-timeline-attachment' property is omitted,
462+
it is set to its [=initial value=].
463+
370464
# View Progress Timelines # {#view-timelines}
371465

372466
Often animations are desired to start and end
@@ -496,9 +590,10 @@ spec: cssom-view-1; type: dfn;
496590
the [=scroll offset=] corresponding to
497591
the end of the ''animation-timeline-range/cover'' range
498592

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=].
593+
The timeline is [=inactive timeline|inactive=] when:
594+
- The 0% position and 100% position coincide
595+
(i.e. the denominator in the [=timeline/current time=] formula is zero), or
596+
- The timeline has no [=current attachment=].
502597

503598
## Anonymous View Progress Timelines ## {#view-timelines-anonymous}
504599

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

760+
The [=used value=] of 'view-timeline-axis'
761+
is the axis of the [=current attachment=],
762+
or the initial value if there is no [=current attachment=].
763+
665764
### Inset of a View Progress Timeline: the 'view-timeline-inset' property ### {#view-timeline-inset}
666765

667766
<pre class='propdef'>
@@ -695,18 +794,49 @@ spec: cssom-view-1; type: dfn;
695794
defines an inward offset from the corresponding edge of the scrollport.
696795
</dl>
697796

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

700825
<pre class='propdef shorthand'>
701826
Name: view-timeline
702-
Value: [ <<'view-timeline-name'>> <<'view-timeline-axis'>>? ]#
827+
Value: [ <<'view-timeline-name'>> [ <<'view-timeline-axis'>> | <<'view-timeline-attachment'>> ]? ]#
703828
Applies to: all elements
704829
</pre>
705830

706831
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'.
832+
'view-timeline-name' and either 'view-timeline-axis' or 'view-timeline-attachment'
833+
in a single declaration. It does not set 'view-timeline-inset'.
834+
835+
If the 'view-timeline-axis' property is omitted,
836+
it is set to its [=initial value=].
837+
838+
If the 'view-timeline-attachment' property is omitted,
839+
it is set to its [=initial value=].
710840

711841
ISSUE: Should it reset 'view-timeline-inset' also?
712842

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

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

781911
## Animation Events ## {#events}
782912

0 commit comments

Comments
 (0)