Skip to content

Commit e4ac7f2

Browse files
authored
Add scrollIntoView() container option (#40588)
1 parent 6358207 commit e4ac7f2

File tree

1 file changed

+22
-11
lines changed
  • files/en-us/web/api/element/scrollintoview

1 file changed

+22
-11
lines changed

files/en-us/web/api/element/scrollintoview/index.md

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ visible to the user.
1818
```js-nolint
1919
scrollIntoView()
2020
scrollIntoView(alignToTop)
21-
scrollIntoView(scrollIntoViewOptions)
21+
scrollIntoView(options)
2222
```
2323

2424
### Parameters
@@ -33,29 +33,40 @@ scrollIntoView(scrollIntoViewOptions)
3333
of the visible area of the scrollable ancestor. Corresponds to
3434
`scrollIntoViewOptions: {block: "end", inline: "nearest"}`.
3535

36-
- `scrollIntoViewOptions` {{optional_inline}}
37-
{{experimental_inline}}
38-
- : An Object with the following properties:
36+
- `options` {{optional_inline}}
37+
- : An object with the following properties:
3938
- `behavior` {{optional_inline}}
40-
- : Determines whether scrolling is instant or animates smoothly. This option is a string which must take one of the following values:
39+
- : Determines whether scrolling is instant or animates smoothly. Its value can be one of the following:
4140
- `smooth`: scrolling should animate smoothly
4241
- `instant`: scrolling should happen instantly in a single jump
4342
- `auto`: scroll behavior is determined by the computed value of {{cssxref("scroll-behavior")}}
43+
44+
The default is `auto`.
45+
4446
- `block` {{optional_inline}}
45-
- : Defines the vertical alignment of the element within the scrollable ancestor container. This option is a string and accepts one of the following values:
47+
- : Defines the vertical alignment of the element within the scrollable ancestor container. Its value can be one of the following:
4648
- `start`: Aligns the element's top edge with the top of the scrollable container, making the element appear at the start of the visible area vertically.
4749
- `center`: Aligns the element vertically at the center of the scrollable container, positioning it in the middle of the visible area.
4850
- `end`: Aligns the element's bottom edge with the bottom of the scrollable container, placing the element at the end of the visible area vertically.
49-
- `nearest`: Scrolls the element to the nearest edge in the vertical direction. If the element is closer to the top edge of the scrollable container, it will align to the top; if it's closer to the bottom
50-
edge, it will align to the bottom. This minimizes the scrolling distance.
51-
- Defaults to `start`.
51+
- `nearest`: Scrolls the element to the nearest edge in the vertical direction. If the element is closer to the top edge of the scrollable container, it will align to the top; if it's closer to the bottom edge, it will align to the bottom. This minimizes the scrolling distance.
52+
53+
The default is `start`.
54+
55+
- `container` {{optional_inline}}
56+
- : Defines the scrollable ancestor container. Its value can be one of the following:
57+
- `all`: All scrollable containers are impacted (including the viewport).
58+
- `nearest`: Only the nearest scrollable container is impacted by the scroll.
59+
60+
The default is `all`.
61+
5262
- `inline` {{optional_inline}}
53-
- : Defines the horizontal alignment of the element within the scrollable ancestor container. This option is a string and accepts one of the following values:
63+
- : Defines the horizontal alignment of the element within the scrollable ancestor container. Its value can be one of the following:
5464
- `start`: Aligns the element's left edge with the left of the scrollable container, making the element appear at the start of the visible area horizontally.
5565
- `center`: Aligns the element horizontally at the center of the scrollable container, positioning it in the middle of the visible area.
5666
- `end`: Aligns the element's right edge with the right of the scrollable container, placing the element at the end of the visible area horizontally.
5767
- `nearest`: Scrolls the element to the nearest edge in the horizontal direction. If the element is closer to the left edge of the scrollable container, it will align to the left; if it's closer to the right edge, it will align to the right. This minimizes the scrolling distance.
58-
- Defaults to `nearest`.
68+
69+
The default is `nearest`.
5970

6071
### Return value
6172

0 commit comments

Comments
 (0)