Skip to content

Commit 0a39585

Browse files
authored
[scroll-animations-1] Removed fill from ScrollTimeline (w3c#4750)
* Fixed edit link by correcting shortname. Removed fill from ScrollTimeline in favor of returning Infinity values for before start and after end states of the timeline. * Removing unecessary editor * Swapped infinity values for 0 and time range. * Updated examples to include forward fill modes so that effects remain after scrolling past the end of the timeline * Added TODO to revisit the spec when animation timeline state has been more discussed
1 parent 8f93050 commit 0a39585

1 file changed

Lines changed: 14 additions & 61 deletions

File tree

scroll-animations-1/Overview.bs

Lines changed: 14 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Work Status: exploring
77
Group: CSSWG
88
URL: https://drafts.csswg.org/scroll-animations-1/
99
ED: https://drafts.csswg.org/scroll-animations-1/
10-
Shortname: scroll-animations
10+
Shortname: scroll-animations-1
1111
Abstract: Defines an API and markup for creating animations that are either
1212
triggered by or tied to the scroll offset of a scroll container.
1313
Editor: Brian Birtles <bbirtles@mozilla.com>
@@ -184,6 +184,7 @@ Using the CSS markup:
184184
}
185185
#union-circle {
186186
animation-name: union-circle;
187+
animation-fill-mode: forwards;
187188
animation-timeline: scroll(element(#container), vertical, "250px", "300px");
188189
}
189190
@keyframes left-circle {
@@ -214,7 +215,7 @@ if (window.matchMedia('(prefers-reduced-motion: no-preference)').matches) {
214215
var right = leftCircle.animate({ transform: 'translate(350px)' }, 1000);
215216
right.timeline = circleTimeline;
216217

217-
var union = unionCircle.animate({ opacity: 1 }, 1000);
218+
var union = unionCircle.animate({ opacity: 1 }, { duration: 1000, fill: "forwards" });
218219
union.timeline = new ScrollTimeline({
219220
scrollSource: scrollableElement,
220221
startScrollOffset: '250px',
@@ -257,6 +258,7 @@ as follows:
257258
height: 30px;
258259
background: red;
259260
animation: progress 1s linear;
261+
animation-fill-mode: forwards;
260262
animation-timeline: scroll(element(#body));
261263
}
262264
}
@@ -266,7 +268,7 @@ If we use this API for this case, the example code will be as follow:
266268

267269
<pre class='lang-javascript'>
268270
if (window.matchMedia('(prefers-reduced-motion: no-preference)').matches) {
269-
var animation = div.animate({ width: '100%' }, 1000);
271+
var animation = div.animate({ width: '100%' }, { duration: 1000, fill: "forwards" });
270272
animation.timeline = new ScrollTimeline(
271273
{ startScrollOffset: '0px' }
272274
);
@@ -371,7 +373,6 @@ dictionary ScrollTimelineOptions {
371373
DOMString startScrollOffset = "auto";
372374
DOMString endScrollOffset = "auto";
373375
(double or ScrollTimelineAutoKeyword) timeRange = "auto";
374-
FillMode fill = "none";
375376
};
376377

377378
[Exposed=Window,
@@ -382,7 +383,6 @@ interface ScrollTimeline : AnimationTimeline {
382383
readonly attribute DOMString startScrollOffset;
383384
readonly attribute DOMString endScrollOffset;
384385
readonly attribute (double or ScrollTimelineAutoKeyword) timeRange;
385-
readonly attribute FillMode fill;
386386
};
387387
</pre>
388388

@@ -410,7 +410,7 @@ not by wall-clock time, but by the progress of scrolling in a [=scroll container
410410

411411
1. Set the {{ScrollTimeline/scrollSource}} of |timeline| to |source|.
412412

413-
1. Assign the {{ScrollTimeline/orientation}}, {{ScrollTimeline/startScrollOffset}}, {{ScrollTimeline/endScrollOffset}}, {{ScrollTimeline/timeRange}}, and {{ScrollTimeline/fill}} properties of |timeline| to the corresponding value from |options|.
413+
1. Assign the {{ScrollTimeline/orientation}}, {{ScrollTimeline/startScrollOffset}}, {{ScrollTimeline/endScrollOffset}}, and {{ScrollTimeline/timeRange}} properties of |timeline| to the corresponding value from |options|.
414414

415415
</div>
416416

@@ -475,39 +475,6 @@ not by wall-clock time, but by the progress of scrolling in a [=scroll container
475475
the mapping is then defined by mapping the scroll distance from
476476
{{startScrollOffset}} to {{endScrollOffset}}, to the [=effective time range=].
477477

478-
: <dfn attribute for=ScrollTimeline>fill</dfn>
479-
:: Determines whether the timeline is active even when the scroll offset is outside
480-
the range defined by [{{startScrollOffset}}, {{endScrollOffset}}].
481-
482-
Possible values are:
483-
484-
: none
485-
:: The timeline is inactive when the scroll offset is less than {{startScrollOffset}}
486-
or greater than or equal to {{endScrollOffset}}.
487-
488-
: forwards
489-
:: When the scroll offset is less than {{startScrollOffset}}, the
490-
timeline is inactive.
491-
When the scroll offset is greater than or equal to the
492-
{{endScrollOffset}}, the timeline's [=current time=] is its
493-
[=effective time range=].
494-
495-
: backwards
496-
:: When the scroll offset is less than {{startScrollOffset}}, the
497-
timeline's [=current time=] is 0.
498-
When the scroll offset is greater than or equal to the
499-
{{endScrollOffset}}, the timeline is inactive.
500-
501-
: both
502-
:: When the scroll offset is less than {{startScrollOffset}}, the
503-
timeline's [=current time=] is 0.
504-
When the scroll offset is greater than or equal to the
505-
{{endScrollOffset}}, the timeline's [=current time=] is its
506-
[=effective time range=].
507-
508-
: auto
509-
:: Behaves the same as <code>both</code>.
510-
511478
</div>
512479

513480
### The effective time range of a {{ScrollTimeline}} ### {#efffective-time-range-algorithm}
@@ -542,25 +509,11 @@ as follows:
542509
1. Otherwise, let <var>current scroll offset</var> be the current scroll offset of {{scrollSource}}
543510
in the direction specified by {{orientation}}.
544511

545-
1. If <var>current scroll offset</var> is less than {{startScrollOffset}}, return an unresolved
546-
time value if {{fill}} is <code>none</code> or <code>forwards</code>, or 0 otherwise.
547-
548-
1. If <var>current scroll offset</var> is greater than or equal to {{endScrollOffset}} then:
549-
<div class="switch">
550-
551-
: If {{endScrollOffset}} is less than the maximum scroll offset of {{scrollSource}} in
552-
{{orientation}} and {{fill}} is <code>none</code> or <code>backwards</code>,
553-
554-
:: return an unresolved time value.
512+
1. If <var>current scroll offset</var> is less than {{startScrollOffset}}, return 0.
555513

556-
: Otherwise,
514+
Note: TODO(<a href="https://github.com/w3c/csswg-drafts/issues/4325#issuecomment-585295758">Issue 4325</a>): Define what the correct timeline state is based on scroll offset.
557515

558-
:: return the [=effective time range=].
559-
560-
</div>
561-
562-
Note: Checking for {{endScrollOffset}} being the maximum scroll offset ensures that the common
563-
case of a 'whole scroller' ScrollTimeline does not become inactive when you scroll to the end.
516+
1. If <var>current scroll offset</var> is greater than or equal to {{endScrollOffset}}, return [=effective time range=].
564517

565518
1. Return the result of evaluating the following expression:
566519

@@ -589,7 +542,7 @@ Computed value: As specified
589542
Canonical order: per grammar
590543
</pre>
591544

592-
<dfn>&lt;single-animation-timeline></dfn> = auto | scroll([element(<<id-selector>>)[, <<scroll-direction>>[, <<scroll-offset>>[, <<scroll-offset>>[, <<time>>[, <<single-animation-fill-mode>>]]]]]])
545+
<dfn>&lt;single-animation-timeline></dfn> = auto | scroll([element(<<id-selector>>)[, <<scroll-direction>>[, <<scroll-offset>>[, <<scroll-offset>>[, <<time>>]]]]])
593546

594547
<dfn>&lt;scroll-direction></dfn> = auto | block | inline | horizontal | vertical
595548

@@ -610,7 +563,7 @@ following effects:
610563
:: The animation's [=timeline=] is a {{DocumentTimeline}}, more specifically the
611564
<a>default document timeline</a>.
612565

613-
: scroll([element(<<id-selector>>)[, <<scroll-direction>>[, <<scroll-offset>>[, <<scroll-offset>>[, <<time>>[, <<single-animation-fill-mode>>]]]]]])
566+
: scroll([element(<<id-selector>>)[, <<scroll-direction>>[, <<scroll-offset>>[, <<scroll-offset>>[, <<time>>]]]]])
614567
:: The animation's [=timeline=] is a {{ScrollTimeline}}.
615568

616569
The timeline's {{scrollSource}} is the [=scroll container=] identified
@@ -624,8 +577,6 @@ following effects:
624577

625578
The <<time>> value, if specified, determines the timeline's {{timeRange}}.
626579

627-
The <<single-animation-fill-mode>> value, if specified, determines the timeline's {{fill}}.
628-
629580
</div> <!-- link-for-hint="ScrollTimeline" -->
630581

631582
## Examples ## {#timeline-examples}
@@ -652,7 +603,8 @@ following effects:
652603
],
653604
{
654605
duration: 1000,
655-
easing: "linear"
606+
easing: "linear",
607+
fill: "forwards"
656608
});
657609
let timeline = new ScrollTimeline({
658610
scrollSource: document.documentElement,
@@ -684,6 +636,7 @@ following effects:
684636
background-color: red;
685637
animation-name: progress;
686638
animation-duration: 1s;
639+
animation-fill-mode: forwards;
687640
animation-timing-function: linear;
688641
/* Assume the HTML element has id 'root' */
689642
animation-timeline: scroll(element(#root), vertical);

0 commit comments

Comments
 (0)