You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[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]>
@@ -1291,16 +1294,19 @@ The <dfn method for=Element caniuse=scrollintoview>scrollIntoView(<var>arg</var>
1291
1294
1. Let <var>behavior</var> be "<code>auto</code>".
1292
1295
1. Let <var>block</var> be "<code>start</code>".
1293
1296
1. Let <var>inline</var> be "<code>nearest</code>".
1297
+
1. Let <var>container</var> be <code>null</code>.
1294
1298
1. If <var>arg</var> is a {{ScrollIntoViewOptions}} dictionary, then:
1295
1299
1. Set <var>behavior</var> to the {{ScrollOptions/behavior}} dictionary member of <var>options</var>.
1296
1300
1. Set <var>block</var> to the {{ScrollIntoViewOptions/block}} dictionary member of <var>options</var>.
1297
1301
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.
1298
1304
1. Otherwise, if <var>arg</var> is false, then set <var>block</var> to "<code>end</code>".
1299
1305
1. If the element does not have any associated [=CSS/box=],
1300
1306
or is not available to user-agent features,
1301
1307
then return.
1302
1308
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>.
1304
1310
1. Optionally perform some other action that brings the element to the user's attention.
1305
1311
1306
1312
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:
1513
1519
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>,
1514
1520
with a scroll behavior <var>behavior</var>,
1515
1521
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>,
0 commit comments