@@ -72,7 +72,7 @@ type ScrollProps = {
7272 /**
7373 * The target represents the scrollable element to check for scroll detection.
7474 */
75- target ?: Element
75+ target ?: HTMLDivElement
7676 /**
7777 * The thr represents the threshold value for scroll detection.
7878 */
@@ -136,7 +136,7 @@ function useDetectScroll(props: ScrollProps = {}): ScrollInfo {
136136 scrollDown = axis === Axis . Y ? Direction . Down : Direction . Right ,
137137 still = Direction . Still
138138 } = props ;
139-
139+
140140 const [ scrollDir , setScrollDir ] = useState < Direction > ( still ) ;
141141 const [ scrollPosition , setScrollPosition ] = useState < ScrollPosition > ( {
142142 top : 0 ,
@@ -183,7 +183,7 @@ function useDetectScroll(props: ScrollProps = {}): ScrollInfo {
183183 return ( ) => {
184184 target === window ? window . removeEventListener ( 'scroll' , updateScrollPosition ) : target . removeEventListener ( 'scroll' , updateScrollPosition ) ;
185185 } ;
186- } , [ ] ) ;
186+ } , [ target ] ) ;
187187
188188 useEffect ( ( ) => {
189189 lastScroll . current = axis === Axis . Y ? window . scrollY : window . scrollX ;
@@ -199,7 +199,7 @@ function useDetectScroll(props: ScrollProps = {}): ScrollInfo {
199199 target === window ? window . addEventListener ( 'scroll' , onScroll ) : target . addEventListener ( 'scroll' , onScroll ) ;
200200
201201 return ( ) => target === window ? window . removeEventListener ( 'scroll' , onScroll ) : target . removeEventListener ( 'scroll' , onScroll ) ;
202- } , [ axis , updateScrollDir ] ) ;
202+ } , [ target , axis , updateScrollDir ] ) ;
203203
204204 return { scrollDir, scrollPosition } ;
205205}
0 commit comments