|
| 1 | +  |
| 2 | + |
| 3 | + |
1 | 4 | # Vue Use Active Scroll |
2 | 5 |
|
3 | | -**Examples:** Vite: [Demo App]() — Nuxt Content: [Nested TOC](https://stackblitz.com/edit/github-oh85gq?file=components%2FSidebar.vue) |
| 6 | +**Examples:** Vite: [Demo App](https://vue-use-active-scroll.netlify.app) — Nuxt Content: [Nested TOC](https://stackblitz.com/edit/github-oh85gq?file=components%2FSidebar.vue) |
4 | 7 |
|
5 | 8 | :bulb: Requires Vue 3 or above. |
6 | 9 |
|
@@ -153,15 +156,15 @@ const { isActive, setActive } = useActive(targets, { |
153 | 156 | }) |
154 | 157 | ``` |
155 | 158 |
|
156 | | -| Property | Type | Default | Description | |
157 | | -| -------------- | ------------------ | ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
158 | | -| jumpToFirst | `boolean` | true | Whether to set the first target on mount as active even if not (yet) intersecting. | |
159 | | -| jumpToLast | `boolean` | true | Whether to set the last target as active once reached the bottom even if previous targets are entirely visible. | |
160 | | -| boundaryOffset | `BoundaryOffset` | { toTop: 0, toBottom: 0 } | Boundary offset in px for each scroll direction. Tweak them to "anticipate" or "delay" target detection. | |
161 | | -| rootId | `string` \| `null` | null | Id of the scrolling element. Set it only if your content **is not scrolled** by the window. | |
162 | | -| replaceHash | `boolean` | false | Whether to replace URL hash on scroll. First target is ignored if `jumpToFirst` is true. | |
163 | | -| overlayHeight | `number` | 0 | Height in pixels of any **CSS fixed** content that overlaps the top of your scrolling area (e.g. fixed header). Must be paired with a CSS [scroll-margin-top]() rule. | |
164 | | -| minWidth | `number` | 0 | Whether to toggle listeners and functionalities within a specific width. Useful if hiding the sidebar using `display: none`. | |
| 159 | +| Property | Type | Default | Description | |
| 160 | +| -------------- | ------------------ | ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
| 161 | +| jumpToFirst | `boolean` | true | Whether to set the first target on mount as active even if not (yet) intersecting. | |
| 162 | +| jumpToLast | `boolean` | true | Whether to set the last target as active once reached the bottom even if previous targets are entirely visible. | |
| 163 | +| boundaryOffset | `BoundaryOffset` | { toTop: 0, toBottom: 0 } | Boundary offset in px for each scroll direction. Tweak them to "anticipate" or "delay" target detection. | |
| 164 | +| rootId | `string` \| `null` | null | Id of the scrolling element. Set it only if your content **is not scrolled** by the window. | |
| 165 | +| replaceHash | `boolean` | false | Whether to replace URL hash on scroll. First target is ignored if `jumpToFirst` is true. | |
| 166 | +| overlayHeight | `number` | 0 | Height in pixels of any **CSS fixed** content that overlaps the top of your scrolling area (e.g. fixed header). Must be paired with a CSS [scroll-margin-top](#setting-scroll-margin-top-for-fixed-headers) rule. | |
| 167 | +| minWidth | `number` | 0 | Whether to toggle listeners and functionalities within a specific width. Useful if hiding the sidebar using `display: none`. | |
165 | 168 |
|
166 | 169 | ### Return object |
167 | 170 |
|
@@ -326,7 +329,7 @@ html { |
326 | 329 |
|
327 | 330 | <br /> |
328 | 331 |
|
329 | | -## Adjusting overlayHeight targets' margin |
| 332 | +## Setting scroll-margin-top for fixed headers |
330 | 333 |
|
331 | 334 | You might noticed that if you have a fixed header and defined an `overlayHeight`, once you click to scroll to a target it may be underneath the header. You must set `scroll-margin-top` to your targets: |
332 | 335 |
|
|
0 commit comments