Skip to content

Commit 4dd6811

Browse files
committed
[cssom-view] Change scrollIntoView({}) to center, and add "nearest"
* Change default value of ScrollIntoViewOptions to center/center. * Add a "nearest" value to ScrollLogicalPosition. * scrollIntoView() and scrollIntoView(true|false) use start/end for block flow direction and nearest for inline base direction.
1 parent 76e9602 commit 4dd6811

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

cssom-view/Overview.bs

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -991,10 +991,10 @@ Extensions to the {{Element}} Interface {#extension-to-the-element-interface}
991991
=============================================================================
992992

993993
<pre class=idl>
994-
enum ScrollLogicalPosition { "start", "center", "end" };
994+
enum ScrollLogicalPosition { "start", "center", "end", "nearest" };
995995
dictionary ScrollIntoViewOptions : ScrollOptions {
996-
ScrollLogicalPosition block = "start";
997-
ScrollLogicalPosition inline;
996+
ScrollLogicalPosition block = "center";
997+
ScrollLogicalPosition inline = "center";
998998
};
999999

10001000
partial interface Element {
@@ -1056,7 +1056,8 @@ The <dfn method for=Element>scrollIntoView(<var>arg</var>)</dfn> method must run
10561056
1. Let <var>options</var> be null.
10571057
1. If <var>arg</var> is an object, let <var>options</var> be <var>arg</var>.
10581058
1. <a lt="converted to an IDL value">Convert</a> <var>options</var> to a {{ScrollIntoViewOptions}} dictionary. [[!WEBIDL]]
1059-
1. If <var>arg</var> is false, let the {{ScrollIntoViewOptions/block}} dictionary member of <var>options</var> have the value "<code>end</code>".
1059+
1. If <var>arg</var> is not specified or is true, let the {{ScrollIntoViewOptions/block}} dictionary member of <var>options</var> have the value "<code>start</code>", and let the {{ScrollIntoViewOptions/inline}} dictionary member of <var>options</var> have the value "<code>nearest</code>".
1060+
1. If <var>arg</var> is false, let the {{ScrollIntoViewOptions/block}} dictionary member of <var>options</var> have the value "<code>end</code>", and let the {{ScrollIntoViewOptions/inline}} dictionary member of <var>options</var> have the value "<code>nearest</code>".
10601061
1. If the element does not have any associated <a>layout box</a> terminate these steps.
10611062
1. <a lt='scroll an element into view'>Scroll the element into view</a>
10621063
with the options <var>options</var>.
@@ -1236,11 +1237,24 @@ a <a>scrolling box</a> <var>scrolling box</var>, in order of innermost to outerm
12361237

12371238
1. If the {{ScrollIntoViewOptions/block}} dictionary member of <var>options</var> is "start", align <var>element edge A</var> with <var>scrolling box edge A</var>.
12381239
1. Otherwise, if the {{ScrollIntoViewOptions/block}} dictionary member of <var>options</var> is "end"; align <var>element edge B</var> with <var>scrolling box edge B</var>.
1239-
1. Otherwise, it is "center"; align the center of <var>element bounding border box</var> with the center of <var>scrolling box</var> in <var>scrolling box</var>'s <a>block flow direction</a>.
1240+
1. Otherwise, if the {{ScrollIntoViewOptions/block}} dictionary member of <var>options</var> is "center"; align the center of <var>element bounding border box</var> with the center of <var>scrolling box</var> in <var>scrolling box</var>'s <a>block flow direction</a>.
1241+
1. Otherwise, it is "nearest"; follow these steps:
1242+
<dl class=switch>
1243+
<dt>If <var>element edge A</var> and <var>element edge B</var> are both outside <var>scrolling box edge A</var> and <var>scrolling box edge B</var>
1244+
<dd>Do nothing.
1245+
1246+
<dt>If <var>element edge A</var> is outside <var>scrolling box edge A</var> and <var>element width</var> is less than <var>scrolling box width</var>
1247+
<dt>If <var>element edge B</var> is outside <var>scrolling box edge B</var> and <var>element width</var> is greater than <var>scrolling box width</var>
1248+
<dd>Align <var>element edge A</var> with <var>scrolling box edge A</var>.
1249+
1250+
<dt>If <var>element edge A</var> is outside <var>scrolling box edge A</var> and <var>element width</var> is greater than <var>scrolling box width</var>
1251+
<dt>If <var>element edge B</var> is outside <var>scrolling box edge B</var> and <var>element width</var> is less than <var>scrolling box width</var>
1252+
<dd>Align <var>element edge B</var> with <var>scrolling box edge B</var>.
1253+
</dl>
12401254
1. If the {{ScrollIntoViewOptions/inline}} dictionary member of <var>options</var> is "start", align <var>element edge C</var> with <var>scrolling box edge C</var>.
12411255
1. Otherwise, if the {{ScrollIntoViewOptions/inline}} dictionary member of <var>options</var> is "end"; align <var>element edge D</var> with <var>scrolling box edge D</var>.
12421256
1. Otherwise, if the {{ScrollIntoViewOptions/inline}} dictionary member of <var>options</var> is "center", align the center of <var>element bounding border box</var> with the center of <var>scrolling box</var> in <var>scrolling box</var>'s <a>inline base direction</a>.
1243-
1. Otherwise, it is not set; follow these steps:
1257+
1. Otherwise, it is "nearest"; follow these steps:
12441258
<dl class=switch>
12451259
<dt>If <var>element edge C</var> and <var>element edge D</var> are both outside <var>scrolling box edge C</var> and <var>scrolling box edge D</var>
12461260
<dd>Do nothing.

0 commit comments

Comments
 (0)