Skip to content

Commit e8d30ac

Browse files
flackrtabatkins
andauthored
[cssom-view-1] Add container option to scrollIntoView options. (#11673)
* [cssom-view-1] Add container option to scrollIntoView options. Adds the container option to ScrollIntoViewOptions allowing scrolling only the nearest containing scrolling box as resolved in #9452. * Update cssom-view-1/Overview.bs --------- Co-authored-by: Tab Atkins Jr. <[email protected]>
1 parent f386e97 commit e8d30ac

File tree

1 file changed

+31
-21
lines changed

1 file changed

+31
-21
lines changed

cssom-view-1/Overview.bs

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,8 +1166,11 @@ enum ScrollLogicalPosition { "start", "center", "end", "nearest" };
11661166
dictionary ScrollIntoViewOptions : ScrollOptions {
11671167
ScrollLogicalPosition block = "start";
11681168
ScrollLogicalPosition inline = "nearest";
1169+
ScrollIntoViewContainer container = "all";
11691170
};
11701171

1172+
enum ScrollIntoViewContainer { "all", "nearest" };
1173+
11711174
dictionary CheckVisibilityOptions {
11721175
boolean checkOpacity = false;
11731176
boolean checkVisibilityCSS = false;
@@ -1291,16 +1294,19 @@ The <dfn method for=Element caniuse=scrollintoview>scrollIntoView(<var>arg</var>
12911294
1. Let <var>behavior</var> be "<code>auto</code>".
12921295
1. Let <var>block</var> be "<code>start</code>".
12931296
1. Let <var>inline</var> be "<code>nearest</code>".
1297+
1. Let <var>container</var> be <code>null</code>.
12941298
1. If <var>arg</var> is a {{ScrollIntoViewOptions}} dictionary, then:
12951299
1. Set <var>behavior</var> to the {{ScrollOptions/behavior}} dictionary member of <var>options</var>.
12961300
1. Set <var>block</var> to the {{ScrollIntoViewOptions/block}} dictionary member of <var>options</var>.
12971301
1. Set <var>inline</var> to the {{ScrollIntoViewOptions/inline}} dictionary member of <var>options</var>.
1302+
1. If the {{ScrollIntoViewOptions/container}} dictionary member of <var>options</var>,
1303+
set <var>container</var> to this element.
12981304
1. Otherwise, if <var>arg</var> is false, then set <var>block</var> to "<code>end</code>".
12991305
1. If the element does not have any associated [=CSS/box=],
13001306
or is not available to user-agent features,
13011307
then return.
13021308
1. <a lt='scroll a target into view'>Scroll the element into view</a>
1303-
with <var>behavior</var>, <var>block</var>, and <var>inline</var>.
1309+
with <var>behavior</var>, <var>block</var>, <var>inline</var>, and <var>container</var>.
13041310
1. Optionally perform some other action that brings the element to the user's attention.
13051311

13061312
The <dfn method for=Element lt="scroll(options)|scroll(x, y)">scroll()</dfn> method must run these steps:
@@ -1513,26 +1519,30 @@ run the following steps:
15131519
To <dfn export>scroll a target into view</dfn> <var>target</var>, which is an <a for="/">Element</a>, [=pseudo-element=], or <a>Range</a>,
15141520
with a scroll behavior <var>behavior</var>,
15151521
a block flow direction position <var>block</var>,
1516-
and an inline base direction position <var>inline</var>,
1517-
means to run these steps for each ancestor element or <a>viewport</a> that establishes
1518-
a <a>scrolling box</a> <var>scrolling box</var>, in order of innermost to outermost <a>scrolling box</a>:
1519-
1520-
1. If the {{Document}} associated with <var>target</var> is not <a>same origin</a> with the {{Document}} associated with the element or <a>viewport</a> associated with <var>scrolling box</var>, terminate these steps.
1521-
1. Let <var>position</var> be the scroll position resulting from running the steps to <a>determine the scroll-into-view position</a> of <var>target</var> with <var>behavior</var> as the |scroll behavior|,
1522-
<var>block</var> as the |block flow position|, <var>inline</var> as the |inline base direction position| and <var>scrolling box</var> as the |scrolling box|.
1523-
1. If <var>position</var> is the same as <var>scrolling box</var>'s current scroll position, and <var>scrolling box</var> does not have an ongoing <a>smooth scroll</a>, then return.
1524-
1. <dl class=switch>
1525-
<dt>If <var>scrolling box</var> is associated with an element
1526-
<dd>
1527-
<a for="/">Perform a scroll</a> of the element's <var>scrolling box</var> to <var>position</var>, with the element as the associated element and
1528-
<var>behavior</var> as the scroll behavior.
1529-
<dt>If <var>scrolling box</var> is associated with a <a>viewport</a>
1530-
<dd>
1531-
1. Let <var>document</var> be the <a>viewport’s</a> associated {{Document}}.
1532-
1. Let <var>root element</var> be <var>document</var>'s [=root element=], if there is one, or null otherwise.
1533-
1. <a for="viewport">Perform a scroll</a> of the <a>viewport</a> to <var>position</var>, with <var>root element</var> as the associated element and <var>behavior</var>
1534-
as the scroll behavior.
1535-
</dl>
1522+
an inline base direction position <var>inline</var>,
1523+
and an optional containing <a>Element</a> to stop scrolling after reaching <var>container</var>,
1524+
means to run these steps:
1525+
1526+
1. For each ancestor element or <a>viewport</a> that establishes a <a>scrolling box</a> <var>scrolling box</var>,
1527+
in order of innermost to outermost <a>scrolling box</a>, run these substeps:
1528+
1. If the {{Document}} associated with <var>target</var> is not <a>same origin</a> with the {{Document}} associated with the element or <a>viewport</a> associated with <var>scrolling box</var>, terminate these steps.
1529+
1. Let <var>position</var> be the scroll position resulting from running the steps to <a>determine the scroll-into-view position</a> of <var>target</var> with <var>behavior</var> as the |scroll behavior|,
1530+
<var>block</var> as the |block flow position|, <var>inline</var> as the |inline base direction position| and <var>scrolling box</var> as the |scrolling box|.
1531+
1. If <var>position</var> is not the same as <var>scrolling box</var>'s current scroll position, or <var>scrolling box</var> has an ongoing <a>smooth scroll</a>,
1532+
1. <dl class=switch>
1533+
<dt>If <var>scrolling box</var> is associated with an element
1534+
<dd>
1535+
<a for="/">Perform a scroll</a> of the element's <var>scrolling box</var> to <var>position</var>, with the element as the associated element and
1536+
<var>behavior</var> as the scroll behavior.
1537+
<dt>If <var>scrolling box</var> is associated with a <a>viewport</a>
1538+
<dd>
1539+
1. Let <var>document</var> be the <a>viewport’s</a> associated {{Document}}.
1540+
1. Let <var>root element</var> be <var>document</var>'s [=root element=], if there is one, or null otherwise.
1541+
1. <a for="viewport">Perform a scroll</a> of the <a>viewport</a> to <var>position</var>, with <var>root element</var> as the associated element and <var>behavior</var>
1542+
as the scroll behavior.
1543+
</dl>
1544+
1. If <var>container</var> is not null and <var>scrolling box</var> is a [=shadow-including inclusive ancestor=] of <var>container</var>,
1545+
abort the rest of these steps.
15361546

15371547
</div>
15381548

0 commit comments

Comments
 (0)