@@ -14,9 +14,10 @@ import {
14
14
ref ,
15
15
getEdges ,
16
16
useMediaRef ,
17
+ isScrollbarClick ,
17
18
isSSR ,
18
- FIXED_OFFSET ,
19
19
defaultOptions as def ,
20
+ FIXED_OFFSET ,
20
21
} from './utils'
21
22
import type { UseActiveOptions , ShortRef , Targets } from './types'
22
23
@@ -134,13 +135,19 @@ export function useActive(userTargets: Targets, options: UseActiveOptions = def)
134
135
* Utils - Scroll
135
136
* ==================================================================================== */
136
137
137
- function setActive ( { prevY, isCancel = false } : { prevY : number ; isCancel ?: boolean } ) {
138
+ function setActive ( {
139
+ prevY,
140
+ isScrollCancel = false ,
141
+ } : {
142
+ prevY : number
143
+ isScrollCancel ?: boolean
144
+ } ) {
138
145
const nextY = getCurrentY ( )
139
146
140
147
if ( nextY < prevY ) {
141
148
onScrollUp ( )
142
149
} else {
143
- onScrollDown ( { isCancel } )
150
+ onScrollDown ( { isScrollCancel } )
144
151
}
145
152
146
153
return nextY
@@ -163,7 +170,7 @@ export function useActive(userTargets: Targets, options: UseActiveOptions = def)
163
170
}
164
171
165
172
// Sets first target-top that LEFT the root
166
- function onScrollDown ( { isCancel } = { isCancel : false } ) {
173
+ function onScrollDown ( { isScrollCancel } = { isScrollCancel : false } ) {
167
174
let firstOutEl = jumpToFirst ? targets . els [ 0 ] : null
168
175
169
176
const sentinel = getSentinel ( )
@@ -196,7 +203,7 @@ export function useActive(userTargets: Targets, options: UseActiveOptions = def)
196
203
if ( isNext || ( firstOutEl && ! activeEl . v ) ) return ( activeEl . v = firstOutEl )
197
204
198
205
// ...but not on scroll cancel
199
- if ( isCancel ) activeEl . v = firstOutEl
206
+ if ( isScrollCancel ) activeEl . v = firstOutEl
200
207
}
201
208
202
209
// Sets first target-bottom that ENTERED the root
@@ -345,13 +352,15 @@ export function useActive(userTargets: Targets, options: UseActiveOptions = def)
345
352
346
353
function onScrollCancel ( event : PointerEvent ) {
347
354
const isAnchor = ( event . target as HTMLElement ) . tagName === 'A'
355
+ const isFireFox = window . CSS . supports ( '-moz-appearance' , 'none' )
356
+ const isScrollbar = isScrollbarClick ( event )
348
357
349
- if ( ! isAnchor ) {
358
+ if ( ( isFireFox || isScrollbar ) && ! isAnchor ) {
350
359
const { isBottom, isTop } = getEdges ( root . v )
351
360
352
361
if ( ! isTop && ! isBottom ) {
353
362
restoreHighlight ( )
354
- setActive ( { prevY : clickStartY . v , isCancel : true } )
363
+ setActive ( { prevY : clickStartY . v , isScrollCancel : true } )
355
364
}
356
365
}
357
366
}
0 commit comments