Skip to content

Commit f3ad38f

Browse files
Passing root to isScrollbarClick
1 parent 24b2dad commit f3ad38f

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

src/useActive.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -355,15 +355,11 @@ export function useActive(userTargets: Targets, options: UseActiveOptions = def)
355355

356356
if (!isAnchor) {
357357
const isFireFox = window.CSS.supports('-moz-appearance', 'none')
358-
const isScrollbar = isScrollbarClick(event)
358+
const isScrollbar = isScrollbarClick(event, root.v)
359359

360360
if (isFireFox || isScrollbar) {
361-
const { isBottom, isTop } = getEdges(root.v)
362-
363-
if (!isTop && !isBottom) {
364-
restoreHighlight()
365-
setActive({ prevY: clickStartY.v, isScrollCancel: true })
366-
}
361+
restoreHighlight()
362+
setActive({ prevY: clickStartY.v, isScrollCancel: true })
367363
}
368364
}
369365
}

src/utils.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,10 @@ export function getEdges(root: HTMLElement) {
6969
}
7070
}
7171

72-
export const isScrollbarClick = (event: PointerEvent) => event.clientX >= window.innerWidth - 17
72+
export const isScrollbarClick = (event: PointerEvent, root: HTMLElement) => {
73+
const containerWidth = root === document.documentElement ? window.innerWidth : root.clientWidth
74+
return event.clientX >= containerWidth - 17
75+
}
7376

7477
export const defaultOptions = {
7578
jumpToFirst: true,

0 commit comments

Comments
 (0)