@@ -15,7 +15,7 @@ import {
1515 BrushingType ,
1616 BrushPageOffset ,
1717} from './types' ;
18- import { getPageCoordinates } from './utils' ;
18+ import { debounce , getPageCoordinates } from './utils' ;
1919
2020type PointerHandlerEvent = React . PointerEvent < SVGRectElement > ;
2121
@@ -177,14 +177,14 @@ export default class BaseBrush extends React.Component<BaseBrushProps, BaseBrush
177177 componentDidMount ( ) {
178178 if ( this . props . useWindowMoveEvents ) {
179179 window . addEventListener ( 'mouseup' , this . handleWindowPointerUp ) ;
180- window . addEventListener ( 'mousemove' , this . handleWindowPointerMove ) ;
180+ window . addEventListener ( 'mousemove' , this . debouncedHandleWindowPointerMove ) ;
181181 }
182182 }
183183
184184 componentWillUnmount ( ) {
185185 if ( this . props . useWindowMoveEvents ) {
186186 window . removeEventListener ( 'mouseup' , this . handleWindowPointerUp ) ;
187- window . removeEventListener ( 'mousemove' , this . handleWindowPointerMove ) ;
187+ window . removeEventListener ( 'mousemove' , this . debouncedHandleWindowPointerMove ) ;
188188 }
189189 }
190190
@@ -320,6 +320,8 @@ export default class BaseBrush extends React.Component<BaseBrushProps, BaseBrush
320320 }
321321 } ;
322322
323+ debouncedHandleWindowPointerMove = debounce ( this . handleWindowPointerMove , 1 ) ;
324+
323325 getExtent = ( start : Partial < Point > , end : Partial < Point > ) => {
324326 const { brushDirection, width, height } = this . props ;
325327 const x0 = brushDirection === 'vertical' ? 0 : Math . min ( start . x || 0 , end . x || 0 ) ;
0 commit comments