From c62e2d8df0f8bbdfedfb6d71bbf09d1ca353253f Mon Sep 17 00:00:00 2001 From: Abdo Date: Fri, 19 Apr 2024 12:13:56 +0300 Subject: [PATCH] Fix spacebar causing stutter when editing cards (#3150) * Fix spacebar causing stutter when editing cards * Remove IO toolbar event handlers on unmount * Remove nested keydown handlers --- ts/routes/image-occlusion/Toolbar.svelte | 188 +++++++++++-------- ts/routes/image-occlusion/tools/tool-zoom.ts | 18 -- 2 files changed, 106 insertions(+), 100 deletions(-) diff --git a/ts/routes/image-occlusion/Toolbar.svelte b/ts/routes/image-occlusion/Toolbar.svelte index 8941ab39a..cc2f58956 100644 --- a/ts/routes/image-occlusion/Toolbar.svelte +++ b/ts/routes/image-occlusion/Toolbar.svelte @@ -5,8 +5,11 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
diff --git a/ts/routes/image-occlusion/tools/tool-zoom.ts b/ts/routes/image-occlusion/tools/tool-zoom.ts index d7285c720..6f2c1374e 100644 --- a/ts/routes/image-occlusion/tools/tool-zoom.ts +++ b/ts/routes/image-occlusion/tools/tool-zoom.ts @@ -132,24 +132,6 @@ export const onMouseMove = (opt) => { onDrag(canvas, opt); }; -// initializes lastPosX and lastPosY because it is undefined in touchmove event -document.addEventListener("touchstart", (e) => { - const canvas = globalThis.canvas; - canvas.lastPosX = e.touches[0].clientX; - canvas.lastPosY = e.touches[0].clientY; -}); - -// initializes lastPosX and lastPosY because it is undefined before mousemove event -document.addEventListener("mousemove", (event) => { - document.addEventListener("keydown", (e) => { - if (e.key === " ") { - const canvas = globalThis.canvas; - canvas.lastPosX = event.clientX; - canvas.lastPosY = event.clientY; - } - }); -}); - export const onPinchZoom = (opt): boolean => { const { e } = opt; const canvas = globalThis.canvas;