|
1 | 1 | import { watch, onMounted, ref, computed, type Ref, type ComputedRef } from 'vue'; |
2 | | -import { isSSR, useMediaRef } from './utils'; |
| 2 | +import { isChrome, isSSR, useMediaRef } from './utils'; |
3 | 3 |
|
4 | 4 | type UseListenersOptions = { |
5 | 5 | isWindow: ComputedRef<boolean>; |
@@ -70,14 +70,15 @@ export function useScroll({ isWindow, root, _setActive, matchMedia }: UseListene |
70 | 70 | } |
71 | 71 | } |
72 | 72 |
|
73 | | - function resetReady() { |
| 73 | + function waitForIdle() { |
74 | 74 | setReady(20); |
75 | 75 | } |
76 | 76 |
|
77 | 77 | function onPointerDown(event: PointerEvent) { |
78 | 78 | const isLink = (event.target as HTMLElement).tagName === 'A'; |
79 | 79 | const hasLink = (event.target as HTMLElement).closest('a'); |
80 | | - if (!isLink && !hasLink) { |
| 80 | + |
| 81 | + if (!isChrome && !isLink && !hasLink) { |
81 | 82 | reScroll(); |
82 | 83 | // ...and force set if canceling scroll |
83 | 84 | _setActive(clickY.value, { isCancel: true }); |
@@ -124,19 +125,19 @@ export function useScroll({ isWindow, root, _setActive, matchMedia }: UseListene |
124 | 125 | const rootEl = isWindow.value ? document : root.value; |
125 | 126 |
|
126 | 127 | if (_isClick && rootEl) { |
127 | | - rootEl.addEventListener('scroll', resetReady, ONCE); |
| 128 | + rootEl.addEventListener('scroll', waitForIdle, ONCE); |
128 | 129 | rootEl.addEventListener('wheel', reScroll, ONCE); |
| 130 | + rootEl.addEventListener('touchmove', reScroll, ONCE); |
129 | 131 | rootEl.addEventListener('keydown', onSpaceBar as EventListener, ONCE); |
130 | | - rootEl.addEventListener('touchmove', reScroll as EventListener, ONCE); |
131 | 132 | rootEl.addEventListener('pointerdown', onPointerDown as EventListener, ONCE); |
132 | 133 | } |
133 | 134 |
|
134 | 135 | onCleanup(() => { |
135 | 136 | if (_isClick && rootEl) { |
136 | | - rootEl.removeEventListener('scroll', resetReady); |
| 137 | + rootEl.removeEventListener('scroll', waitForIdle); |
137 | 138 | rootEl.removeEventListener('wheel', reScroll); |
| 139 | + rootEl.removeEventListener('touchmove', reScroll); |
138 | 140 | rootEl.removeEventListener('keydown', onSpaceBar as EventListener); |
139 | | - rootEl.removeEventListener('touchmove', reScroll as EventListener); |
140 | 141 | rootEl.removeEventListener('pointerdown', onPointerDown as EventListener); |
141 | 142 | } |
142 | 143 | }); |
|
0 commit comments