From d286a6fda8a246f6d814bc0be2ec83a896869f58 Mon Sep 17 00:00:00 2001 From: Martin Vladic Date: Mon, 30 Sep 2024 10:59:12 +0200 Subject: [PATCH] #561 --- .../project-editor/flow/runtime/wasm-runtime.tsx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/project-editor/flow/runtime/wasm-runtime.tsx b/packages/project-editor/flow/runtime/wasm-runtime.tsx index 2b1040e8..e3876b4e 100644 --- a/packages/project-editor/flow/runtime/wasm-runtime.tsx +++ b/packages/project-editor/flow/runtime/wasm-runtime.tsx @@ -1313,10 +1313,15 @@ export const WasmCanvas = observer( }; onWheel = (event: WheelEvent) => { - if (this.canvasRef.current) { - this.canvasRef.current.focus(); + if (!this.canvasRef.current) { + return; } + event.preventDefault(); + event.stopPropagation(); + + this.canvasRef.current.focus(); + const wasmRuntime = this.context.runtime as WasmRuntime; if (!wasmRuntime) { return; @@ -1399,7 +1404,9 @@ export const WasmCanvas = observer( this.onPointerCancel, true ); - document.addEventListener("wheel", this.onWheel, true); + canvas.addEventListener("wheel", this.onWheel, { + passive: false + }); canvas.focus(); } @@ -1425,7 +1432,7 @@ export const WasmCanvas = observer( this.onPointerCancel, true ); - document.removeEventListener("wheel", this.onWheel, true); + canvas.removeEventListener("wheel", this.onWheel, false); } }