11import { clsx } from 'clsx' ;
2- import { raf } from '@rc-component/util' ;
2+ import { raf , useEvent } from '@rc-component/util' ;
33import * as React from 'react' ;
44import { getPageXY } from './hooks/useScrollDrag' ;
55
@@ -88,15 +88,15 @@ const ScrollBar = React.forwardRef<ScrollBarRef, ScrollBarProps>((props, ref) =>
8888 const stateRef = React . useRef ( { top, dragging, pageY : pageXY , startTop } ) ;
8989 stateRef . current = { top, dragging, pageY : pageXY , startTop } ;
9090
91- const onThumbMouseDown = ( e : React . MouseEvent | React . TouchEvent | TouchEvent ) => {
91+ const onThumbMouseDown = useEvent ( ( e : React . MouseEvent | React . TouchEvent | TouchEvent ) => {
9292 setDragging ( true ) ;
9393 setPageXY ( getPageXY ( e , horizontal ) ) ;
9494 setStartTop ( stateRef . current . top ) ;
9595
9696 onStartMove ( ) ;
9797 e . stopPropagation ( ) ;
9898 e . preventDefault ( ) ;
99- } ;
99+ } ) ;
100100
101101 // ======================== Effect ========================
102102
@@ -117,7 +117,7 @@ const ScrollBar = React.forwardRef<ScrollBarRef, ScrollBarProps>((props, ref) =>
117117 scrollbarEle . removeEventListener ( 'touchstart' , onScrollbarTouchStart ) ;
118118 thumbEle . removeEventListener ( 'touchstart' , onThumbMouseDown ) ;
119119 } ;
120- } , [ ] ) ;
120+ } , [ onThumbMouseDown ] ) ;
121121
122122 // Pass to effect
123123 const enableScrollRangeRef = React . useRef < number | undefined > ( undefined ) ;
0 commit comments