Skip to content

Commit 5962577

Browse files
committed
Fix: zoom gestures
1 parent 99ff3b6 commit 5962577

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

src/components/workspace/zoom.tsx

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -90,22 +90,16 @@ const Zoom = (props: Pick<ISTKProps, "mode" | "styles" | "options">) => {
9090
if (selectedTool == Tool.Pan) {
9191
selection.call(zoom);
9292
} else {
93-
selection
94-
.call(zoom)
95-
.on("mousedown.zoom", null)
96-
.on("touchstart.zoom", null)
97-
.on("touchmove.zoom", null)
98-
.on("touchend.zoom", null)
99-
.on("wheel.zoom", (e) => {
100-
e.preventDefault();
101-
const currentZoom = selection.property("__zoom").k || 1;
102-
if (e.ctrlKey) {
103-
const nextZoom = currentZoom * Math.pow(2, -e.deltaY * 0.01);
104-
zoom.scaleTo(selection, nextZoom, d3Extended.pointer(e));
105-
} else {
106-
zoom.translateBy(selection, -(e.deltaX / currentZoom), -(e.deltaY / currentZoom));
107-
}
108-
});
93+
selection.call(zoom).on("wheel.zoom", (e) => {
94+
e.preventDefault();
95+
const currentZoom = selection.property("__zoom").k || 1;
96+
if (e.ctrlKey) {
97+
const nextZoom = currentZoom * Math.pow(2, -e.deltaY * 0.01);
98+
zoom.scaleTo(selection, nextZoom, d3Extended.pointer(e));
99+
} else {
100+
zoom.translateBy(selection, -(e.deltaX / currentZoom), -(e.deltaY / currentZoom));
101+
}
102+
});
109103
}
110104
}, [selectedTool]);
111105

0 commit comments

Comments
 (0)