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: README.md
+17-17Lines changed: 17 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,19 +14,17 @@
14
14
The [Intersection Observer](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API) is a great API.
15
15
But it may not be the one-size-fits-all solution to highlight menu/sidebar links.
16
16
17
-
You may noticed that last targets may never intersect if entirely visible in the viewport. Clicking on their links highlights other links or does nothing. In addition to that, the URL hash may not reflect the active link.
17
+
You may noticed that's tricky to customize behavior according to different interactions.
18
18
19
-
But also, it's tricky to customize behavior according to different scroll interactions.
20
-
21
-
For example, you want to immediately highlight targets when scroll is originated from click but not when scroll is originated from wheel/touch.
19
+
For example, you want to immediately highlight targets when scroll is originated from click/navigation but not when it is originated from wheel/touch. You want also to highlight any clicked link even if it will never intersect.
22
20
23
21
**Vue Use Active Scroll** implements a custom scroll observer which automatically adapts to different interactions and always returns the "correct" active target.
24
22
25
23
### Features
26
24
27
25
- Precise and stable at any speed
28
26
- CSS scroll-behavior and callback agnostic
29
-
- Adaptive behavior on mount, back/forward navigation, scroll, click, cancel.
| setActive |`(id: string) => void`|:firecracker: Function to include in your click handler to ensure adaptive behavior between any futher scroll/cancel interaction. |
174
-
| isActive |`(id: string) => boolean`| Whether the given Id is active or not |
175
-
| activeId |`Ref<string>`| Id of the active target |
176
-
| activeIndex |`Ref<number>`| Index of the active target in offset order, `0` for the first target and so on. |
| setActive |`(id: string) => void`|:firecracker: Function to include in your click handler to ensure adaptive behavior between any interaction that may cancel or resume scroll. |
172
+
| isActive |`(id: string) => boolean`| Whether the given Id is active or not |
173
+
| activeId |`Ref<string>`| Id of the active target |
174
+
| activeIndex |`Ref<number>`| Index of the active target in offset order, `0` for the first target and so on. |
> :bulb:If you using native CSS scroll-behavior, [adding the rule](#define-scroll-behavior)to your CSS is enough. No need to set it again in Vue Router.
392
+
> :bulb:There's need to define _smooth_ or _auto_ here. Adding the [CSS rule](#2-define-scroll-behavior) is enough. Same applies below.
393
393
394
-
### Containers
394
+
### Container
395
395
396
-
If you want to scroll to a target inside a container, you must use `scrollIntoView`:
396
+
To scroll to a target scrolled by a container, you must use `scrollIntoView`:
0 commit comments