11import React , { Component , ReactNode , CSSProperties } from "react" ;
2- import throttle from "./utils/ throttle" ;
2+ import { throttle } from ' throttle-debounce' ;
33import { ThresholdUnits , parseThreshold } from "./utils/threshold" ;
44
55type Fn = ( ) => any ;
@@ -41,7 +41,7 @@ export default class InfiniteScroll extends Component<Props, State> {
4141 } ;
4242
4343 this . onScrollListener = this . onScrollListener . bind ( this ) ;
44- this . throttledOnScrollListener = throttle ( this . onScrollListener , 150 ) . bind (
44+ this . throttledOnScrollListener = throttle ( 150 , this . onScrollListener ) . bind (
4545 this
4646 ) ;
4747 this . onStart = this . onStart . bind ( this ) ;
@@ -50,7 +50,7 @@ export default class InfiniteScroll extends Component<Props, State> {
5050 this . getScrollableTarget = this . getScrollableTarget . bind ( this ) ;
5151 }
5252
53- private throttledOnScrollListener : ( ) => void ;
53+ private throttledOnScrollListener : ( e : MouseEvent ) => void ;
5454 private _scrollableNode : HTMLElement | undefined | null ;
5555 private el : HTMLElement | undefined | Window & typeof globalThis ;
5656 private _infScroll : HTMLDivElement | undefined ;
@@ -74,7 +74,7 @@ export default class InfiniteScroll extends Component<Props, State> {
7474 : this . _scrollableNode || window ;
7575
7676 if ( this . el ) {
77- this . el . addEventListener ( "scroll" , this . throttledOnScrollListener ) ;
77+ this . el . addEventListener ( "scroll" , ( e ) => this . throttledOnScrollListener ( e as MouseEvent ) ) ;
7878 }
7979
8080 if (
@@ -116,7 +116,7 @@ export default class InfiniteScroll extends Component<Props, State> {
116116
117117 componentWillUnmount ( ) {
118118 if ( this . el ) {
119- this . el . removeEventListener ( "scroll" , this . throttledOnScrollListener ) ;
119+ this . el . removeEventListener ( "scroll" , ( e ) => this . throttledOnScrollListener ( e as MouseEvent ) ) ;
120120
121121 if ( this . props . pullDownToRefresh ) {
122122 this . el . removeEventListener ( "touchstart" , this . onStart ) ;
0 commit comments