Skip to content

Commit ac6da93

Browse files
committed
edit readme, prettier, pkg, comment
1 parent 1541c17 commit ac6da93

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

.prettierrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
{
88
"files": "README.md",
99
"options": {
10-
"printWidth": 100,
10+
"printWidth": 80,
1111
"trailingComma": "none",
1212
"useTabs": false,
1313
"semi": false

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
The [Intersection Observer](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API) is a great API.
1212
But it may not be the one-size-fits-all solution to highlight menu/sidebar links.
1313

14-
You may noticed that clicking on some links highlights the wrong one (or does nothing) or that the active link doesn't reflect the one in the URL hash. But most important, you noticed that's tricky to obtain different behaviors according to different scroll interactions.
14+
In some cases, you may noticed that last targets may never intersect and that by clicking on the correspondent links highlights the wrong ones (or does nothing). Same may happen with the URL hash, which in some cases may not reflect the actual active target.
15+
16+
But most important, you noticed that's tricky to customize behavior according to different scroll interactions.
1517

1618
For example, you want to immediately highlight targets when scroll is originated from click but not when scroll is originated from wheel/touch.
1719

@@ -97,7 +99,9 @@ const { isActive } = useActive(targets)
9799
Nuxt Content automatically applies IDs to your headings. You can get the TOC links by accessing `data.body.toc.links` via [queryContent](https://content.nuxtjs.org/api/composables/query-pages/).
98100

99101
```js
100-
const { data } = await useAsyncData('about', () => queryContent('/about').findOne())
102+
const { data } = await useAsyncData('about', () =>
103+
queryContent('/about').findOne()
104+
)
101105
```
102106

103107
```js

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "vue-use-active-scroll",
33
"version": "0.8.8",
44
"private": false,
5-
"description": "Reactive and accurate TOC/sidebar links without compromises for Vue.",
5+
"description": "Reactive and accurate TOC/sidebar links without compromises for Vue 3.",
66
"keywords": [
77
"vue",
88
"vue3",

src/useScroll.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export function useScroll({ isWindow, root, _setActive, matchMedia }: UseListene
5959
}
6060
}
6161

62-
// Restore "updating" functionalities if scrolling again while scrolling from click...
62+
// Restore "highlighting" if scrolling again while already scrolling from click...
6363
function reScroll() {
6464
isClick.value = false;
6565
}
@@ -70,6 +70,10 @@ export function useScroll({ isWindow, root, _setActive, matchMedia }: UseListene
7070
}
7171
}
7272

73+
function resetReady() {
74+
setReady(20);
75+
}
76+
7377
function onPointerDown(event: PointerEvent) {
7478
const isLink = (event.target as HTMLElement).tagName === 'A';
7579
const hasLink = (event.target as HTMLElement).closest('a');
@@ -114,10 +118,6 @@ export function useScroll({ isWindow, root, _setActive, matchMedia }: UseListene
114118
{ immediate: true, flush: 'sync' }
115119
);
116120

117-
function resetReady() {
118-
setReady(20);
119-
}
120-
121121
watch(
122122
isClick,
123123
(_isClick, _, onCleanup) => {

0 commit comments

Comments
 (0)