mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Cleanup wheel event listener
This commit is contained in:
parent
59effbc796
commit
6cff2e7241
1 changed files with 8 additions and 0 deletions
|
@ -940,6 +940,8 @@ class App extends React.Component<{}, AppState> {
|
|||
this.forceUpdate();
|
||||
};
|
||||
|
||||
private removeWheelEventListener: (() => void) | undefined;
|
||||
|
||||
public render() {
|
||||
return (
|
||||
<div
|
||||
|
@ -1111,10 +1113,16 @@ class App extends React.Component<{}, AppState> {
|
|||
width={window.innerWidth - CANVAS_WINDOW_OFFSET_LEFT}
|
||||
height={window.innerHeight - CANVAS_WINDOW_OFFSET_TOP}
|
||||
ref={canvas => {
|
||||
if (this.removeWheelEventListener) {
|
||||
this.removeWheelEventListener();
|
||||
this.removeWheelEventListener = undefined;
|
||||
}
|
||||
if (canvas) {
|
||||
canvas.addEventListener("wheel", this.handleWheel, {
|
||||
passive: false
|
||||
});
|
||||
this.removeWheelEventListener = () =>
|
||||
canvas.removeEventListener("wheel", this.handleWheel);
|
||||
}
|
||||
}}
|
||||
onMouseDown={e => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue