Skip to content

Commit ec122a9

Browse files
authored
fix: not remove touchstart listenr before unmount (#206)
* fix: not remove touchstart listenr before unmount * chore: move mode
1 parent 884060e commit ec122a9

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/ScrollBar.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ export default class ScrollBar extends React.Component<ScrollBarProps, ScrollBar
5858

5959
componentWillUnmount() {
6060
this.removeEvents();
61+
this.scrollbarRef.current?.removeEventListener('touchstart', this.onScrollbarTouchStart);
62+
this.thumbRef.current?.removeEventListener('touchstart', this.onMouseDown);
6163
clearTimeout(this.visibleTimeout);
6264
}
6365

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

95-
this.scrollbarRef.current?.removeEventListener('touchstart', this.onScrollbarTouchStart);
96-
9797
if (this.thumbRef.current) {
98-
this.thumbRef.current.removeEventListener('touchstart', this.onMouseDown);
9998
this.thumbRef.current.removeEventListener('touchmove', this.onMouseMove);
10099
this.thumbRef.current.removeEventListener('touchend', this.onMouseUp);
101100
}
@@ -122,7 +121,6 @@ export default class ScrollBar extends React.Component<ScrollBarProps, ScrollBar
122121
onMouseMove = (e: MouseEvent | TouchEvent) => {
123122
const { dragging, pageY, startTop } = this.state;
124123
const { onScroll } = this.props;
125-
126124
raf.cancel(this.moveRaf);
127125

128126
if (dragging) {

0 commit comments

Comments
 (0)