From 9142ce8188cc0d7b8847df0c2f11ab47a0b13a50 Mon Sep 17 00:00:00 2001 From: Andray Date: Sat, 16 Mar 2024 16:14:57 +0400 Subject: [PATCH] fix linter and do not require reload page if option was changed --- .../canvas-zoom-and-pan/javascript/zoom.js | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/extensions-builtin/canvas-zoom-and-pan/javascript/zoom.js b/extensions-builtin/canvas-zoom-and-pan/javascript/zoom.js index 63900025f..a575862df 100644 --- a/extensions-builtin/canvas-zoom-and-pan/javascript/zoom.js +++ b/extensions-builtin/canvas-zoom-and-pan/javascript/zoom.js @@ -839,30 +839,31 @@ onUiLoaded(async() => { document.addEventListener("keydown", handleMoveKeyDown); document.addEventListener("keyup", handleMoveKeyUp); + // Prevent firefox to open toolbar on pressing alt - if (hotkeysConfig.canvas_hotkey_zoom === "Alt") { - let isAltPressed = false; + let isAltPressed = false; - function handleAltKeyDown(e) { - if (!activeElement) return; - if (e.code === "AltLeft" || e.code === "AltRight") { - isAltPressed = true; - } else { - isAltPressed = false; - } - } - - function handleAltKeyUp(e) { - if (isAltPressed) { - e.preventDefault(); - } + function handleAltKeyDown(e) { + if (!activeElement) return; + if (hotkeysConfig.canvas_hotkey_zoom !== "Alt") return; + if (e.code === "AltLeft" || e.code === "AltRight") { + isAltPressed = true; + } else { isAltPressed = false; } - - document.addEventListener("keydown", handleAltKeyDown); - document.addEventListener("keyup", handleAltKeyUp); } + function handleAltKeyUp(e) { + if (hotkeysConfig.canvas_hotkey_zoom !== "Alt") return; + if (isAltPressed) { + e.preventDefault(); + } + isAltPressed = false; + } + + document.addEventListener("keydown", handleAltKeyDown); + document.addEventListener("keyup", handleAltKeyUp); + // Detect zoom level and update the pan speed. function updatePanPosition(movementX, movementY) {