From 1ea67ba93dd45ab45647ed6e40b02442ff5beb9a Mon Sep 17 00:00:00 2001 From: Aakansha Doshi Date: Thu, 14 Jul 2022 11:08:20 +0530 Subject: [PATCH] fix: attach wheel event to exscalidraw container only (#5443) --- src/components/App.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/components/App.tsx b/src/components/App.tsx index f88d069a..7f7efa39 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -950,7 +950,10 @@ class App extends React.Component { document.removeEventListener(EVENT.COPY, this.onCopy); document.removeEventListener(EVENT.PASTE, this.pasteFromClipboard); document.removeEventListener(EVENT.CUT, this.onCut); - document.removeEventListener(EVENT.WHEEL, this.onWheel); + this.excalidrawContainerRef.current?.removeEventListener( + EVENT.WHEEL, + this.onWheel, + ); this.nearestScrollableContainer?.removeEventListener( EVENT.SCROLL, this.onScroll, @@ -999,7 +1002,11 @@ class App extends React.Component { this.removeEventListeners(); document.addEventListener(EVENT.POINTER_UP, this.removePointer); // #3553 document.addEventListener(EVENT.COPY, this.onCopy); - document.addEventListener(EVENT.WHEEL, this.onWheel, { passive: false }); + this.excalidrawContainerRef.current?.addEventListener( + EVENT.WHEEL, + this.onWheel, + { passive: false }, + ); if (this.props.handleKeyboardGlobally) { document.addEventListener(EVENT.KEYDOWN, this.onKeyDown, false);