@@ -163,9 +163,7 @@ export function useActive(
163163 }
164164
165165 // ...but not on scroll cancel
166- if ( isCancel ) {
167- activeId . v = firstOut
168- }
166+ if ( isCancel ) activeId . v = firstOut
169167 }
170168
171169 // Sets first target-bottom that ENTERED the viewport
@@ -260,9 +258,7 @@ export function useActive(
260258 function setFromHash ( ) {
261259 const hashId = targets . elements . find ( ( { id } ) => id === location . hash . slice ( 1 ) ) ?. id
262260
263- if ( hashId ) {
264- return ( activeId . v = hashId ) , true
265- }
261+ if ( hashId ) return ( activeId . v = hashId ) , true
266262 }
267263
268264 function onHashChange ( event : HashChangeEvent ) {
@@ -293,9 +289,7 @@ export function useActive(
293289 if ( ! skipObserverCallback ) {
294290 setTargets ( )
295291 requestAnimationFrame ( ( ) => {
296- if ( ! onEdgeReached ( ) ) {
297- onScrollDown ( )
298- }
292+ if ( ! onEdgeReached ( ) ) onScrollDown ( )
299293 } )
300294 } else {
301295 skipObserverCallback = false
@@ -316,9 +310,7 @@ export function useActive(
316310 }
317311
318312 function onSpaceBar ( event : KeyboardEvent ) {
319- if ( event . code === 'Space' ) {
320- restoreHighlight ( )
321- }
313+ if ( event . code === 'Space' ) restoreHighlight ( )
322314 }
323315
324316 function onFirefoxCancel ( event : PointerEvent ) {
@@ -360,9 +352,7 @@ export function useActive(
360352 addHashChangeListener ( )
361353
362354 // Hash has priority only on mount...
363- if ( ! setFromHash ( ) && ! onEdgeReached ( ) ) {
364- onScrollDown ( )
365- }
355+ if ( ! setFromHash ( ) && ! onEdgeReached ( ) ) onScrollDown ( )
366356 }
367357 } )
368358
@@ -383,9 +373,7 @@ export function useActive(
383373 addHashChangeListener ( )
384374
385375 // ...but not on resize
386- if ( ! onEdgeReached ( ) ) {
387- onScrollDown ( )
388- }
376+ if ( ! onEdgeReached ( ) ) onScrollDown ( )
389377 } else {
390378 activeId . v = ''
391379 removeHashChangeListener ( )
@@ -402,15 +390,11 @@ export function useActive(
402390 const isActive = rootEl && _isScrollIdle && _matchMedia && unref ( _userIds ) ?. length > 0
403391
404392 if ( isActive ) {
405- rootEl . addEventListener ( 'scroll' , onScroll , {
406- passive : true ,
407- } )
393+ rootEl . addEventListener ( 'scroll' , onScroll , { passive : true } )
408394 }
409395
410396 onCleanup ( ( ) => {
411- if ( isActive ) {
412- rootEl . removeEventListener ( 'scroll' , onScroll )
413- }
397+ if ( isActive ) rootEl . removeEventListener ( 'scroll' , onScroll )
414398 } )
415399 }
416400 )
@@ -427,6 +411,7 @@ export function useActive(
427411 rootEl . addEventListener ( 'wheel' , restoreHighlight , { once : true } )
428412 rootEl . addEventListener ( 'touchmove' , restoreHighlight , { once : true } )
429413 rootEl . addEventListener ( 'scroll' , setIdleScroll as unknown as EventListener , {
414+ passive : true ,
430415 once : true ,
431416 } )
432417 rootEl . addEventListener ( 'keydown' , onSpaceBar as EventListener , { once : true } )
0 commit comments