From 59625778f4de7646cc642ed223eb6a74252c40e7 Mon Sep 17 00:00:00 2001 From: Akalanka Perera Date: Fri, 12 Apr 2024 11:21:21 +0530 Subject: [PATCH] Fix: zoom gestures --- src/components/workspace/zoom.tsx | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/src/components/workspace/zoom.tsx b/src/components/workspace/zoom.tsx index 9f2c9be..0d1d46d 100644 --- a/src/components/workspace/zoom.tsx +++ b/src/components/workspace/zoom.tsx @@ -90,22 +90,16 @@ const Zoom = (props: Pick) => { if (selectedTool == Tool.Pan) { selection.call(zoom); } else { - selection - .call(zoom) - .on("mousedown.zoom", null) - .on("touchstart.zoom", null) - .on("touchmove.zoom", null) - .on("touchend.zoom", null) - .on("wheel.zoom", (e) => { - e.preventDefault(); - const currentZoom = selection.property("__zoom").k || 1; - if (e.ctrlKey) { - const nextZoom = currentZoom * Math.pow(2, -e.deltaY * 0.01); - zoom.scaleTo(selection, nextZoom, d3Extended.pointer(e)); - } else { - zoom.translateBy(selection, -(e.deltaX / currentZoom), -(e.deltaY / currentZoom)); - } - }); + selection.call(zoom).on("wheel.zoom", (e) => { + e.preventDefault(); + const currentZoom = selection.property("__zoom").k || 1; + if (e.ctrlKey) { + const nextZoom = currentZoom * Math.pow(2, -e.deltaY * 0.01); + zoom.scaleTo(selection, nextZoom, d3Extended.pointer(e)); + } else { + zoom.translateBy(selection, -(e.deltaX / currentZoom), -(e.deltaY / currentZoom)); + } + }); } }, [selectedTool]);