Skip to content

Commit

Permalink
fix: not remove touchstart listenr before unmount (#206)
Browse files Browse the repository at this point in the history
* fix: not remove touchstart listenr before unmount

* chore: move mode
  • Loading branch information
linxianxi committed Jul 12, 2023
1 parent 884060e commit ec122a9
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/ScrollBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ export default class ScrollBar extends React.Component<ScrollBarProps, ScrollBar

componentWillUnmount() {
this.removeEvents();
this.scrollbarRef.current?.removeEventListener('touchstart', this.onScrollbarTouchStart);
this.thumbRef.current?.removeEventListener('touchstart', this.onMouseDown);
clearTimeout(this.visibleTimeout);
}

Expand Down Expand Up @@ -92,10 +94,7 @@ export default class ScrollBar extends React.Component<ScrollBarProps, ScrollBar
window.removeEventListener('mousemove', this.onMouseMove);
window.removeEventListener('mouseup', this.onMouseUp);

this.scrollbarRef.current?.removeEventListener('touchstart', this.onScrollbarTouchStart);

if (this.thumbRef.current) {
this.thumbRef.current.removeEventListener('touchstart', this.onMouseDown);
this.thumbRef.current.removeEventListener('touchmove', this.onMouseMove);
this.thumbRef.current.removeEventListener('touchend', this.onMouseUp);
}
Expand All @@ -122,7 +121,6 @@ export default class ScrollBar extends React.Component<ScrollBarProps, ScrollBar
onMouseMove = (e: MouseEvent | TouchEvent) => {
const { dragging, pageY, startTop } = this.state;
const { onScroll } = this.props;

raf.cancel(this.moveRaf);

if (dragging) {
Expand Down

0 comments on commit ec122a9

Please sign in to comment.