Skip to content

Commit eef21e3

Browse files
committed
improve scroll cancel function
1 parent b177861 commit eef21e3

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/useActive.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -352,15 +352,18 @@ export function useActive(userTargets: Targets, options: UseActiveOptions = def)
352352

353353
function onScrollCancel(event: PointerEvent) {
354354
const isAnchor = (event.target as HTMLElement).tagName === 'A'
355-
const isFireFox = window.CSS.supports('-moz-appearance', 'none')
356-
const isScrollbar = isScrollbarClick(event)
357355

358-
if ((isFireFox || isScrollbar) && !isAnchor) {
359-
const { isBottom, isTop } = getEdges(root.v)
356+
if (!isAnchor) {
357+
const isFireFox = window.CSS.supports('-moz-appearance', 'none')
358+
const isScrollbar = isScrollbarClick(event)
360359

361-
if (!isTop && !isBottom) {
362-
restoreHighlight()
363-
setActive({ prevY: clickStartY.v, isScrollCancel: true })
360+
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+
}
364367
}
365368
}
366369
}

0 commit comments

Comments
 (0)