@@ -1551,6 +1551,7 @@ export const Home: React.FC<HomeProps> = ({
15511551
15521552 const navContainerRef = useRef < HTMLDivElement > ( null )
15531553 const isNavDragging = useRef ( false )
1554+ const navHapticIndexRef = useRef < number | null > ( null )
15541555 const bodyUserSelectRef = useRef ( "" )
15551556 const bodyWebkitUserSelectRef = useRef ( "" )
15561557 const [ viewportHeight , setViewportHeight ] = useState ( ( ) =>
@@ -1560,6 +1561,12 @@ export const Home: React.FC<HomeProps> = ({
15601561 const [ navIndicatorY , setNavIndicatorY ] = useState ( 0 )
15611562 const [ isNavDraggingState , setIsNavDraggingState ] = useState ( false )
15621563
1564+ const triggerNavHaptic = useCallback ( ( ) => {
1565+ if ( ! isMobile ) return
1566+ if ( typeof navigator === "undefined" || typeof navigator . vibrate !== "function" ) return
1567+ navigator . vibrate ( 8 )
1568+ } , [ isMobile ] )
1569+
15631570 const quickNavLayout = useMemo ( ( ) => {
15641571 const baseItemSize = 24
15651572 const baseFontSize = 11
@@ -1629,6 +1636,10 @@ export const Home: React.FC<HomeProps> = ({
16291636 const clampedY = Math . max ( innerTop , Math . min ( innerBottom - 0.001 , y ) )
16301637 const index = Math . floor ( ( clampedY - innerTop ) / quickNavLayout . itemSize )
16311638 const safeIndex = Math . max ( 0 , Math . min ( itemCount - 1 , index ) )
1639+ if ( safeIndex !== navHapticIndexRef . current ) {
1640+ navHapticIndexRef . current = safeIndex
1641+ triggerNavHaptic ( )
1642+ }
16321643
16331644 const targetGroup = groupedStudents [ safeIndex ]
16341645 if ( targetGroup ) {
@@ -1637,11 +1648,12 @@ export const Home: React.FC<HomeProps> = ({
16371648 scrollToGroup ( targetGroup . key )
16381649 }
16391650 } ,
1640- [ groupedStudents , quickNavLayout . itemSize , quickNavLayout . paddingY ]
1651+ [ groupedStudents , quickNavLayout . itemSize , quickNavLayout . paddingY , triggerNavHaptic ]
16411652 )
16421653
16431654 const onNavMouseDown = ( e : React . MouseEvent ) => {
16441655 e . preventDefault ( )
1656+ navHapticIndexRef . current = null
16451657 setNavDraggingState ( true )
16461658 handleNavAction ( e . clientY )
16471659 document . addEventListener ( "mousemove" , onGlobalMouseMove )
@@ -1662,6 +1674,7 @@ export const Home: React.FC<HomeProps> = ({
16621674 }
16631675
16641676 const onNavTouchStart = ( e : React . TouchEvent ) => {
1677+ navHapticIndexRef . current = null
16651678 setNavDraggingState ( true )
16661679 if ( e . touches [ 0 ] ) {
16671680 handleNavAction ( e . touches [ 0 ] . clientY )
@@ -1677,6 +1690,7 @@ export const Home: React.FC<HomeProps> = ({
16771690 }
16781691
16791692 const onNavTouchEnd = ( ) => {
1693+ navHapticIndexRef . current = null
16801694 setNavDraggingState ( false )
16811695 }
16821696
0 commit comments