Skip to content

Commit 5622984

Browse files
committed
[scroll-animations-1] Recast timeline attachment as a name binding. w3c#8680 w3c#7759
1 parent 7d71af1 commit 5622984

File tree

1 file changed

+171
-82
lines changed

1 file changed

+171
-82
lines changed

scroll-animations-1/Overview.bs

Lines changed: 171 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ spec: cssom-view-1; type: dfn;
313313
and then referenced by name.
314314
See [[#timeline-scope]].
315315

316-
Named scroll progress timelines are declared in the [=coordinated value list=]
316+
Named [=scroll progress timelines=] are declared in the [=coordinated value list=]
317317
constructed from the [=longhands=] of the 'scroll-timeline' [=shorthand property=],
318318
which form a [=coordinating list property group=]
319319
with 'scroll-timeline-name' as the [=coordinating list base property=].
@@ -325,15 +325,20 @@ spec: cssom-view-1; type: dfn;
325325
Name: scroll-timeline-name
326326
Value: none | <<custom-ident>>#
327327
Initial: none
328-
Applies to: [=scroll containers=]
328+
Applies to: all elements
329329
Inherited: no
330330
Computed value: the keyword ''scroll-timeline-name/none'' or a list of <<custom-ident>>s
331331
Animation type: not animatable
332332
</pre>
333333

334334
Specifies names for the [=scroll progress timelines=]
335-
associated with this [=scroll container=].
336-
The axis for this timeline is given by 'scroll-timeline-axis'.
335+
declared by this element.
336+
337+
On boxes that are not [=scroll containers=],
338+
only names with a 'scroll-timeline-attachment'
339+
of ''scroll-timeline-attachment/defer''
340+
are considered for [[#timeline-scope|scoping and lookup]];
341+
any other name declarations are ignored.
337342

338343
### Axis of a Scroll Progress Timeline: the 'scroll-timeline-axis' property ### {#scroll-timeline-axis}
339344

@@ -347,15 +352,13 @@ spec: cssom-view-1; type: dfn;
347352
Animation type: not animatable
348353
</pre>
349354

350-
Specifies an axis for each [=scroll progress timeline=]
351-
associated with this [=scroll container=].
352-
The name for this timeline is given by 'scroll-timeline-name'.
355+
Specifies an axis for each named [=scroll progress timeline=]
356+
sourced from this [=scroll container=].
353357

354358
Values are as defined for ''scroll()''.
355359

356-
Note: This property has no effect on [=scroll progress timelines=]
357-
that are declared on this element
358-
but whose [=attachment=] is ''scroll-timeline-attachment/defer''.
360+
Note: This property has no effect when combined
361+
with a 'scroll-timeline-attachment' of ''scroll-timeline-attachment/defer''.
359362

360363
### Attachment of a Scroll Progress Timeline: the 'scroll-timeline-attachment' property ### {#scroll-timeline-attachment}
361364

@@ -369,71 +372,76 @@ spec: cssom-view-1; type: dfn;
369372
Animation type: not animatable
370373
</pre>
371374

372-
Specifies attachment behavior for each [=scroll progress timeline=]
373-
associated with this element.
375+
Specifies the [=name attachment=]
376+
of each [=scroll progress timeline=] name
377+
declared by this element (see 'scroll-timeline-name').
378+
379+
As an alternative to attaching locally
380+
(to a timeline sourced from this element),
381+
a declared name’s corresponding
382+
<dfn local-lt=attachment>name attachment</dfn>
383+
can defer to a descendant’s timeline
384+
(''scroll-timeline-attachment/defer'')
385+
or connect this element’s timeline
386+
to a matching name declared by and scoped to an ancestor
387+
(''scroll-timeline-attachment/ancestor''),
388+
allowing its [[#timeline-scope|scope]] to expand
389+
beyond this element and its descendants.
374390

375-
A scroll timeline has a <dfn>attachment</dfn>,
376-
that determines which [=scroll container=] and {{ScrollTimeline/axis}} to use
377-
when calculating the [progress of the timeline](#scroll-timeline-progress).
391+
Values have the following meanings:
378392

379393
<dl dfn-type=value dfn-for=scroll-timeline-attachment>
380394
<dt><dfn>local</dfn>
381395
<dd>
382-
The [=attachment=] is this timeline.
396+
This [=scroll progress timeline=] name
397+
[=attaches=] to the corresponding [=scroll progress timeline=]
398+
defined by this [=scroll container=].
399+
400+
If this box is not a [=scroll container=],
401+
then the corresponding [=scroll progress timeline=] declaration
402+
is ignored.
403+
404+
<!-- This is the same implication as 'scroll-timeline' not applying to [=scroll containers=],
405+
and means that the name not only will not be visible to any descendants’ animation-timeline,
406+
but it also will not block descendants trying to bind to the same name on an ancestor. -->
383407

384408
<dt><dfn>defer</dfn>
385409
<dd>
386-
The [=attachment=] is the timeline among the flat-tree descendants
387-
that satisfies all of the following:
388-
* The timeline has a matching 'scroll-timeline-name'.
389-
* The timeline has [=ancestor=] attachment.
390-
* There is no intermediate ''scroll-timeline-attachment/defer'' timeline
391-
declared with the same name.
392-
393-
If more than one such candidate exists,
394-
then this timeline has no [=attachment=].
410+
This [=scroll progress timeline=] name’s [=attachment=]
411+
is deferred to its descendants.
412+
In other words,
413+
this element declares a [=scroll progress timeline=]’s name
414+
and defines its scope (see [[#timeline-scope]]),
415+
but defers the timeline’s definition
416+
([=scroll container=] source and axis)
417+
to its descendants.
418+
419+
If more than one matching descendant [=scroll progress timeline=] exists,
420+
or if no such timeline exists,
421+
then the timeline name has no [=attachment=],
422+
and represents an [=inactive timeline=].
423+
424+
ISSUE: Should it instead be ignored (be invisible to lookup)?
425+
(This might make it harder to implement.)
426+
If multiple, should it attach instead to the last declared timeline (in tree order)
427+
rather than invalidating the attachment?
395428

396429
<dt><dfn>ancestor</dfn>
397430
<dd>
398-
The timeline has no [=attachment=].
399-
400-
Timelines with [=ancestor=] attachment are treated as nameless
401-
for the purposes of timeline lookup;
402-
they can't be referenced by 'animation-timeline'.
431+
This [=scroll progress timeline=] definition,
432+
attaches to the closest matching [=scroll progress timeline=] name
433+
that was deferred (''scroll-timeline-name/defer'')
434+
by an ancestor (if any).
435+
436+
If no such ancestor exists,
437+
the [=attachment=] is treated as ''scroll-timeline-attachment/local''.
438+
439+
If this box is not a [=scroll container=], however,
440+
then this [=scroll progress timeline=] definition is ignored.
441+
<!-- Not only will it not bind to a name,
442+
it also won't invalidate any other bindings to that name. -->
403443
</dl>
404444

405-
Timelines that have no [=attachment=] are [=inactive timeline|inactive=].
406-
407-
<div class=example>
408-
Using ''scroll-timeline-attachment: defer'',
409-
an element can effectively refer to timelines
410-
that appear <em>after it</em> in tree order.
411-
For example, the following creates an animation on <code>#target</code> that
412-
is ultimately linked to a scroll timeline defined on the subsequent sibling.
413-
414-
<pre class=lang-css>
415-
@keyframes anim {
416-
from { color: red; }
417-
to { color: green; }
418-
}
419-
420-
#root {
421-
scroll-timeline-name: mytimeline;
422-
scroll-timeline-attachment: defer;
423-
}
424-
425-
#root #target {
426-
animation: anim;
427-
animation-timeline: mytimeline;
428-
}
429-
430-
#root #target + #scroller {
431-
scroll-timeline-name: mytimeline;
432-
scroll-timeline-attachment: ancestor;
433-
}
434-
</pre>
435-
</div>
436-
437445
### Scroll Timeline Shorthand: the 'scroll-timeline' shorthand ### {#scroll-timeline-shorthand}
438446

439447
<pre class='propdef shorthand'>
@@ -725,8 +733,8 @@ spec: cssom-view-1; type: dfn;
725733
Animation type: not animatable
726734
</pre>
727735

728-
Specifies names for any [=view progress timelines=]
729-
associated with this element’s [=principal box=].
736+
Specifies names for the [=view progress timelines=]
737+
declared by this element.
730738

731739
### Axis of a View Progress Timeline: the 'view-timeline-axis' property ### {#view-timeline-axis}
732740

@@ -741,11 +749,12 @@ spec: cssom-view-1; type: dfn;
741749
</pre>
742750

743751
Specifies an axis for each named [=view progress timeline=]
744-
associated with this [=scroll container=].
752+
derived from this element’s [=principal box=].
753+
754+
Values are as defined for ''view()''.
745755

746-
Note: This property has no effect on [=scroll progress timelines=]
747-
that are declared on this element
748-
but whose [=attachment=] is ''view-timeline-attachment/defer''.
756+
Note: This property has no effect when combined
757+
with a 'view-timeline-attachment' of ''view-timeline-attachment/defer''.
749758

750759
### Inset of a View Progress Timeline: the 'view-timeline-inset' property ### {#view-timeline-inset}
751760

@@ -780,28 +789,63 @@ spec: cssom-view-1; type: dfn;
780789
defines an inward offset from the corresponding edge of the scrollport.
781790
</dl>
782791

783-
Note: This property has no effect on [=scroll progress timelines=]
784-
that are declared on this element
785-
but whose [=attachment=] is ''view-timeline-attachment/defer''.
792+
Note: This property has no effect when combined
793+
with a 'view-timeline-attachment' of ''view-timeline-attachment/defer''.
786794

787795
### Attachment of a View Progress Timeline: the 'view-timeline-attachment' property ### {#view-timeline-attachment}
788796

789797
<pre class='propdef'>
790798
Name: view-timeline-attachment
791-
Value: <'view-timeline-attachment'>#
799+
Value: [ local | defer | ancestor ]#
792800
Initial: local
793801
Applies to: all elements
794802
Inherited: no
795803
Computed value: a list of the keywords specified
796804
Animation type: not animatable
797805
</pre>
798806

799-
Specifies attachment behavior for each [=view progress timeline=]
800-
associated with this element.
801-
Values and behavior are as for 'view-timeline-attachment',
802-
except that the [=attachment=] also determines
803-
the <a property lt="view-timeline-inset">inset</a> and {{ViewTimeline/subject}}
804-
of the [=view progress timeline=].
807+
Specifies the [=name attachment=]
808+
of each [=view progress timeline=] name
809+
declared by this element (see 'view-timeline-name').
810+
811+
Values have the following meanings:
812+
813+
<dl dfn-type=value dfn-for=view-timeline-attachment>
814+
<dt><dfn>local</dfn>
815+
<dd>
816+
This [=view progress timeline=] name
817+
[=attaches=] to the corresponding [=view progress timeline=]
818+
defined on this box.
819+
820+
<dt><dfn>defer</dfn>
821+
<dd>
822+
This [=view progress timeline=] name’s [=attachment=]
823+
is deferred to its descendants.
824+
In other words,
825+
this element declares a [=view progress timeline=]’s name
826+
and defines its scope (see [[#timeline-scope]]),
827+
but defers the timeline’s definition
828+
([=view progress subject|subject=],
829+
[=scroll container=] source,
830+
axis, and
831+
[=view progress visibility range|visibility range=])
832+
to its descendants.
833+
834+
If more than one matching descendant [=view progress timeline=] exists,
835+
or if no such timeline exists,
836+
then this timeline name has no [=attachment=],
837+
and represents an [=inactive timeline=].
838+
839+
<dt><dfn>ancestor</dfn>
840+
<dd>
841+
This [=view progress timeline=] definition
842+
[=attaches=] to the closest matching [=view progress timeline=] name
843+
that was deferred (''view-timeline-name/defer'')
844+
by an ancestor (if any).
845+
846+
If no such ancestor exists,
847+
the [=attachment=] is treated as ''view-timeline-attachment/local''.
848+
</dl>
805849

806850
### View Timeline Shorthand: the 'view-timeline' shorthand ### {#view-timeline-shorthand}
807851

@@ -871,20 +915,65 @@ spec: cssom-view-1; type: dfn;
871915
The editors would be interested in hearing about
872916
any real use cases for multiple iterations here.
873917

874-
## Named Timeline Scoping ## {#timeline-scope}
918+
## Named Timeline Scoping and Lookup ## {#timeline-scope}
875919

876920
A named [=scroll progress timeline=] or [=view progress timeline=]
877-
is referenceable in 'animation-timeline' by:
878-
* the declaring element itself
921+
is referenceable by:
922+
* the name-declaring element itself
879923
* that element’s descendants
880924

881925
If multiple elements have declared the same timeline name,
882926
the matching timeline is the one declared
883927
on the nearest element in tree order.
884928
In case of a name conflict on the same element,
929+
names declared later in the naming property
930+
('scroll-timeline-name', 'view-timeline-name')
931+
take precedence, and
885932
[=scroll progress timelines=] take precedence over [=view progress timelines=].
886933

887-
Note: Using deferred [=attachment=] effectively allow scoping beyond this.
934+
Note: Although only names on the ancestor chain
935+
are visible to a timeline name lookup,
936+
a deferred [=name attachment=] allows a name declared on an ancestor
937+
to be attached to a timeline sourced elsewhere in its subtree,
938+
effectively allowing lookup of a timeline sourced
939+
from a sibling, cousin, or descendant.
940+
See 'scroll-timeline-attachment'/'view-timeline-attachment'.
941+
942+
<div class=example>
943+
Using ''scroll-timeline-attachment: defer'',
944+
an element can refer to timelines
945+
bound to elements that are siblings, cousins, or even descendants.
946+
For example, the following creates an animation on an element
947+
that is linked to a [=scroll progress timeline=]
948+
defined by the subsequent sibling.
949+
950+
<xmp highlight=html>
951+
<style>
952+
@keyframes anim {
953+
from { color: red; }
954+
to { color: green; }
955+
}
956+
957+
.root {
958+
scroll-timeline: scroller defer;
959+
}
960+
961+
.root .animation {
962+
animation: anim;
963+
animation-timeline: scroller;
964+
}
965+
966+
.root .animation + .scroller {
967+
scroll-timeline: scroller ancestor;
968+
}
969+
</style>
970+
&hellip;
971+
<section class="root">
972+
<div class="animation">Animating Box</div>
973+
<div class="scroller">Scrollable Box</div>
974+
</section>
975+
</xmp>
976+
</div>
888977

889978
## Animation Events ## {#events}
890979

0 commit comments

Comments
 (0)