Skip to content

Commit bf1a16b

Browse files
Update definition of scrollSource to allow it to be null (#34)
This should fix #11, #12, and #13.
1 parent 5a3ce0d commit bf1a16b

File tree

1 file changed

+24
-14
lines changed

1 file changed

+24
-14
lines changed

Overview.bs

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ urlPrefix: https://w3c.github.io/web-animations/; type: dfn; spec: web-animation
2727
text: timeline
2828
urlPrefix: https://drafts.csswg.org/cssom-view/; type: dfn; spec: cssom-view-1
2929
text: CSS layout box
30+
urlPrefix: https://html.spec.whatwg.org/multipage/browsers.html; type: dfn; spec: html
31+
text: document associated with a window; url: concept-document-window
3032
3133
3234
spec:html; type:dfn; for:/; text:browsing context
@@ -341,15 +343,16 @@ behavior under different directionalities and writing modes.
341343
enum ScrollTimelineAutoKeyword { "auto" };
342344

343345
dictionary ScrollTimelineOptions {
344-
Element scrollSource;
346+
Element? scrollSource = null;
345347
ScrollDirection orientation = "block";
346348
DOMString startScrollOffset = "auto";
347349
DOMString endScrollOffset = "auto";
348350
(double or ScrollTimelineAutoKeyword) timeRange = "auto";
349351
FillMode fill = "none";
350352
};
351353

352-
[Constructor(optional ScrollTimelineOptions options)]
354+
[Exposed=Window,
355+
Constructor(optional ScrollTimelineOptions options)]
353356
interface ScrollTimeline : AnimationTimeline {
354357
readonly attribute Element scrollSource;
355358
readonly attribute ScrollDirection orientation;
@@ -368,8 +371,23 @@ not by wall-clock time, but by the progress of scrolling in a [=scroll container
368371
369372

370373
: ScrollTimeline(options)
371-
:: Creates a new {{ScrollTimeline}} object. The attributes of the {{ScrollTimeline}} are
372-
initialized with the respective members of the {{options}} dictionary.
374+
:: Creates a new {{ScrollTimeline}} object using the following procedure:
375+
376+
1. Let |timeline| be a new {{ScrollTimeline}} object.
377+
378+
1. Let |source| be the result corresponding to the first matching condition from below.
379+
380+
: If the |scrollSource| value of |options| is non-null,
381+
:: Let |source| be |scrollSource|
382+
383+
: Otherwise (|scrollSource| is null):
384+
:: Let |source| be the {{scrollingElement}} of the {{Document}} associated with the {{Window}} that is the current global object.
385+
386+
Note: |source| may still be null after this step, e.g. if the {{Document}} has no {{scrollingElement}}.
387+
388+
1. Set the {{ScrollTimeline/scrollSource}} of |timeline| to |source|.
389+
390+
1. Assign the {{ScrollTimeline/orientation}}, {{ScrollTimeline/startScrollOffset}}, {{ScrollTimeline/endScrollOffset}}, {{ScrollTimeline/timeRange}}, and {{ScrollTimeline/fill}} properties of |timeline| to the corresponding value from |options|.
373391

374392
375393

@@ -379,14 +397,6 @@ not by wall-clock time, but by the progress of scrolling in a [=scroll container
379397
:: The scrollable element whose scrolling triggers the activation and drives the
380398
progress of the timeline.
381399

382-
If this is not specified, the {{scrollingElement}} of the [=active document=]
383-
for the current [=browsing context=], as determined at the time the
384-
{{ScrollTimeline}} is constructed, is used.
385-
386-
Note that the {{scrollSource}}'s {{ownerDocument}} may change over the lifetime
387-
of the scroll timeline. This does not affect the scroll timeline; the timeline
388-
continues to be driven by the scroll progress of the {{scrollSource}}.
389-
390400
: orientation
391401
:: Determines the direction of scrolling which triggers the activation and drives
392402
the progress of the trigger.
@@ -503,8 +513,8 @@ The effective time range of a {{ScrollTimeline}} is calculated as fol
503513
The [=current time=] of a {{ScrollTimeline}} is calculated
504514
as follows:
505515

506-
1. If {{scrollSource}} does not currently have a [=CSS layout box=], or if its layout box is not
507-
a [=scroll container=], return an unresolved time value.
516+
1. If {{scrollSource}} is null, does not currently have a [=CSS layout box=], or
517+
if its layout box is not a [=scroll container=], return an unresolved time value.
508518

509519
2. Otherwise, let current scroll offset be the current scroll offset of {{scrollSource}}
510520
in the direction specified by {{orientation}}.

0 commit comments

Comments
 (0)