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
Copy file name to clipboardexpand all lines: docs/modifiers/scroll-into-view.md
+13-5
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,11 @@
1
1
# scroll-into-view
2
2
3
-
This modifier scrolls to the associated element. By default it uses `scrollIntoView`, but if an offset is passed as an option it uses `scrollTo` and calculates the `options.top` attribute.
3
+
This modifier scrolls to the associated element. By default it uses `scrollIntoView`, but if a top or left offset is passed as an option it uses `scrollTo` and calculates the `options.top` and/or `options.left` attribute.
4
4
5
5
6
6
## When you should use this modifier
7
7
8
-
You should use this modifier whenever you need to have an element scrolled into view. If there is a element, such as a fixed header, passing in an `offset`will scroll to the element minus the `offset` value.
8
+
You should use this modifier whenever you need to have an element scrolled into view. If there is a element, such as a fixed header or sidebar, passing in a `topOffset` or `leftOffset`will scroll to the element minus the that offset value.
9
9
10
10
11
11
@@ -27,11 +27,19 @@ You should use this modifier whenever you need to have an element scrolled into
27
27
28
28
### Usage with offset
29
29
30
-
When passing in an offset, it will call `scrollTo`. See [scrollTo](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollTo) for the list of possible values and properties of `options`.
30
+
When passing in an offset, it will call [scrollTo](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollTo), and the `options` parameter is designed to correspond to its `options`. The `options.behavior` operates the same, however, instead of `top` and `left` there are `topOffset` and `leftOffset`, respectively. If an offset value is not set then the value passed to `scrollTo` is 0, e.g. `options = { topOffset: 10 }` results in `element.scrollTo({ top: [computedValue], left: 0 })`. Experiment with the below example, you may need to zoom and resize the window to see a horizontal scrollbar.
0 commit comments