Skip to content

Commit 7fd843a

Browse files
committed
[scroll-animations-1] Replace @timeline with @scroll-timeline (w3c#5008)
1 parent 88aafc3 commit 7fd843a

File tree

2 files changed

+58
-87
lines changed

2 files changed

+58
-87
lines changed

scroll-animations-1/EXPLAINER.md

+14-17
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ A ScrollTimeline is specified by a number of parameters:
144144

145145
#### CSS syntax
146146

147-
We are introducing a new `@timeline` rule similar to the existing `@keyframes` rule. This will allow
147+
We are introducing a new `@scroll-timeline` rule similar to the existing `@keyframes` rule. This will allow
148148
scroll-linked animation to be specified in CSS.
149149

150150
Here is an example to demonstrate this which fades the target as `#scroller` scroll from zero to
@@ -160,9 +160,8 @@ max.
160160
to { opacity: 0 }
161161
}
162162

163-
@timeline fade {
164-
timeline-type: scroll;
165-
scroll-source: selector(#scroller);
163+
@scroll-timeline fade {
164+
source: selector(#scroller);
166165
}
167166
```
168167

@@ -189,20 +188,18 @@ div.circle {
189188
animation-timeline: union-timeline;
190189
}
191190

192-
@timeline collision-timeline {
193-
timeline-type: scroll;
194-
scroll-source: selector(#container);
195-
scroll-direction: block;
196-
scroll-start: 200px;
197-
scroll-end: 300px;
191+
@scroll-timeline collision-timeline {
192+
source: selector(#container);
193+
direction: block;
194+
start: 200px;
195+
end: 300px;
198196
}
199197

200-
@timeline union-timeline {
201-
timeline-type: scroll;
202-
scroll-source: selector(#container);
203-
scroll-direction: block;
204-
scroll-start: 250px;
205-
scroll-end: 300px;
198+
@scroll-timeline union-timeline {
199+
source: selector(#container);
200+
direction: block;
201+
start: 250px;
202+
end: 300px;
206203
}
207204

208205
@keyframes left-circle {
@@ -483,7 +480,7 @@ should consider [logical transforms](https://github.com/w3c/fxtf-drafts/issues/3
483480
## Considered alternatives
484481
485482
### CSS Syntax
486-
We have considered alternatives function based css syntax but decided to go with a @timeline rule
483+
We have considered alternatives function based css syntax but decided to go with a @scroll-timeline rule
487484
instead. See additional CSSWG discussion [here](https://github.com/w3c/csswg-drafts/issues/4338).
488485
489486

scroll-animations-1/Overview.bs

+44-70
Original file line numberDiff line numberDiff line change
@@ -142,20 +142,18 @@ Using the CSS markup:
142142
animation-timeline: union-timeline;
143143
}
144144

145-
@timeline collision-timeline {
146-
timeline-type: scroll;
147-
scroll-source: selector(#container);
148-
scroll-direction: block;
149-
scroll-start: 200px;
150-
scroll-end: 300px;
145+
@scroll-timeline collision-timeline {
146+
source: selector(#container);
147+
orientation: block;
148+
start: 200px;
149+
end: 300px;
151150
}
152151

153-
@timeline union-timeline {
154-
timeline-type: scroll;
155-
scroll-source: selector(#container);
156-
scroll-direction: block;
157-
scroll-start: 250px;
158-
scroll-end: 300px;
152+
@scroll-timeline union-timeline {
153+
source: selector(#container);
154+
orientation: block;
155+
start: 250px;
156+
end: 300px;
159157
}
160158

161159
@keyframes left-circle {
@@ -223,9 +221,8 @@ this example could be written as follows:
223221

224222
<pre class='lang-css'>
225223
@media (prefers-reduced-motion: no-preference) {
226-
@timeline progress-timeline {
227-
timeline-type: scroll;
228-
scroll-source: selector(#body);
224+
@scroll-timeline progress-timeline {
225+
source: selector(#body);
229226
}
230227

231228
@keyframes progress {
@@ -539,15 +536,15 @@ the following effects:
539536

540537

541538
: <<timeline-name>>
542-
:: If ''@timeline'' rule with the name specified by <<timeline-name>>, then
539+
:: If ''@scroll-timeline'' rule with the name specified by <<timeline-name>>, then
543540
the animation's [=timeline=] is a timeline whose property values are
544541
provided by that rule. Otherwise there is no [=timeline=] associated with
545542
the animation.
546543

547544

548545
If 'animation-timeline' property is not specified but 'animation-name' is
549-
specified then its value is used to select the timeline at-rule that provides
550-
the property values for the animation's timeline.
546+
specified then its value is used to select the scroll-timeline at-rule that
547+
provides the property values for the animation's timeline.
551548

552549
Note: Allowing animation-name to be used for selecting timeline enables most
553550
common animations to have to use a single name for both their keyframes and
@@ -566,7 +563,7 @@ In this case, each possible value of type <<keyframes-name>> from
566563

567564

568565
: <<keyframes-name>>
569-
:: If ''@timeline'' rule with the name specified by <<keyframes-name>>, then
566+
:: If ''@scroll-timeline'' rule with the name specified by <<keyframes-name>>, then
570567
the animation's [=timeline=] is a timeline whose property values are
571568
provided by that rule. Otherwise the animation's [=timeline=] is a
572569
{{DocumentTimeline}}, more specifically the <a>default document
@@ -586,106 +583,83 @@ optional <<timeline-name>>.
586583

587584
Issue: Update css-animations spec instead of monkey-patching it here.
588585

589-
## The '@timeline' at-rule ## {#timeline-at-rule}
586+
## The '@scroll-timeline' at-rule ## {#scroll-timeline-at-rule}
590587

591-
[=Scroll Timelines=] are specified in CSS using the <dfn>@timeline</dfn>
588+
[=Scroll Timelines=] are specified in CSS using the <dfn>@scroll-timeline</dfn>
592589
at-rule, defined as follows:
593590

594591
<pre>
595-
@timeline = @timeline <<timeline-name>> { <<declaration-list>> }
592+
@scroll-timeline = @scroll-timeline <<timeline-name>> { <<declaration-list>> }
596593

597594

598595
<dfn>&lt;timeline-name></dfn> = <<custom-ident>> | <<string>>
599596
</pre>
600597

601598

602-
An ''@timeline'' rule has a name given by the <<custom-ident>> or <<string>> in
599+
An ''@scroll-timeline'' rule has a name given by the <<custom-ident>> or <<string>> in
603600
its prelude. The two syntaxes are equivalent in functionality; the name is the
604601
value of the ident or string. As normal for <<custom-ident>>s and <<string>>s,
605602
the names are fully case-sensitive; two names are equal only if they are
606603
codepoint-by-codepoint equal. The <<custom-ident>> additionally excludes the
607604
none keyword.
608605

609606

610-
The <<declaration-list>> inside of ''@timeline'' rule can only contain the
607+
The <<declaration-list>> inside of ''@scroll-timeline'' rule can only contain the
611608
descriptors defined in this section.
612609

613-
### the 'timeline-type' descriptor ### {#timeline-type-descriptors}
614-
615-
616-
<pre class='descdef'>
617-
Name: timeline-type
618-
For: @timeline
619-
Value: scroll | time
620-
Initial: time
621-
</pre>
622-
623-
The 'timeline-type' determines the type of timeline and whose possible values
624-
have the following effects:
625-
626-
: time
627-
:: The animation's [=timeline=] is a {{DocumentTimeline}}, more specifically
628-
the <a>default document timeline</a>.
629-
630-
: scroll
631-
:: The animation's [=timeline=] is a {{ScrollTimeline}} as specified in the
632-
''@timeline'' rule's <<declaration-list>>.
633-
634-
635-
636610
### Scroll Timeline descriptors ### {#scroll-timeline-descriptors}
637611

638612

639613
<pre class='descdef'>
640-
Name: scroll-source
641-
For: @timeline
614+
Name: source
615+
For: @scroll-timeline
642616
Value: selector(<<id-selector>>) | none
643617
Initial: none
644618
</pre>
645619

646-
'scroll-source' descriptor determines the scroll timeline's {{source}}. If
647-
specified as an '<selector()>' the scroll timeline's {{source}} is the
648-
[=scroll container=] identified by the <<id-selector>>, otherwise if not
649-
specified or none then it is the the {{scrollingElement}} of the {{Document}}
650-
<a lt="document associated with a window">associated</a> with the {{Window}}
651-
that is the <a>current global object</a>.
620+
'source' descriptor determines the scroll timeline's {{source}}. If specified as
621+
an '<selector()>' the scroll timeline's {{source}} is the [=scroll container=]
622+
identified by the <<id-selector>>, otherwise if not specified or none then it is
623+
the the {{scrollingElement}} of the {{Document}} <a lt="document associated with
624+
a window">associated</a> with the {{Window}} that is the <a>current global
625+
object</a>.
652626

653627
Issue(4338): consider choosing animation target's nearest scrollable ancestor
654628
instead of document's scrolling Element
655629

656630
<pre class='descdef'>
657-
Name: scroll-orientation
658-
For: @timeline
631+
Name: orientation
632+
For: @scroll-timeline
659633
Value: auto | block | inline | horizontal | vertical
660634
Initial: auto
661635
</pre>
662636

663-
'scroll-orientation' descriptor determines the scroll timeline's {{orientation}}.
637+
'orientation' descriptor determines the scroll timeline's {{orientation}}.
664638

665639

666640
<pre class='descdef'>
667-
Name: scroll-start
668-
For: @timeline
641+
Name: start
642+
For: @scroll-timeline
669643
Value: auto | <<length>> | <<percentage>>
670644
Initial: auto
671645
</pre>
672646

673-
'scroll-start' descriptor determines the scroll timeline's {{start}}.
647+
'start' descriptor determines the scroll timeline's {{start}}.
674648

675649

676650
<pre class='descdef'>
677-
Name: scroll-end
678-
For: @timeline
651+
Name: end
652+
For: @scroll-timeline
679653
Value: auto | <<length>> | <<percentage>>
680654
Initial: auto
681655
</pre>
682656

683-
'scroll-end' descriptor determines the scroll timeline's {{end}}.
657+
'end' descriptor determines the scroll timeline's {{end}}.
684658

685659

686660
<pre class='descdef'>
687661
Name: scroll-time-range
688-
For: @timeline
662+
For: @scroll-timeline
689663
Value: auto | <<time>>
690664
Initial: auto
691665
</pre>
@@ -736,11 +710,10 @@ instead of document's scrolling Element
736710
<pre class="lang-css">
737711
@media (prefers-reduced-motion: no-preference) {
738712

739-
@timeline progress {
740-
timeline-type: scroll;
713+
@scroll-timeline progress {
741714
/* Assume the HTML element has id 'root' */
742-
scroll-source: selector(#root);
743-
scroll-orientation: vertical;
715+
source: selector(#root);
716+
orientation: vertical;
744717
}
745718

746719
@keyframes progress {
@@ -758,7 +731,8 @@ instead of document's scrolling Element
758731
width: 0;
759732
height: 2px;
760733
background-color: red;
761-
/* The same name is used to select keyframes and timeline at-rules */
734+
/* This name is used to select both the keyframes and the
735+
scroll-timeline at-rules. */
762736
animation-name: progress;
763737
animation-duration: 1s;
764738
animation-fill-mode: forwards;

0 commit comments

Comments
 (0)