From 99d77a07f7cd56a34714894501359daac2128bc4 Mon Sep 17 00:00:00 2001 From: Fen Dweller Date: Sun, 3 May 2020 15:41:17 -0400 Subject: [PATCH] Add a toast message for scrolling when locked --- macrovision.js | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/macrovision.js b/macrovision.js index b880c0e9..dd9644f4 100644 --- a/macrovision.js +++ b/macrovision.js @@ -1812,9 +1812,14 @@ document.addEventListener("DOMContentLoaded", () => { } } else { - const dir = e.deltaY < 0 ? 10 / 11 : 11 / 10; - setWorldHeight(config.height, math.multiply(config.height, dir)); - updateWorldOptions(); + if (config.autoFit) { + toastRateLimit("Zoom is locked! Check Settings to disable.", "zoom-lock", 1000); + } else { + const dir = e.deltaY < 0 ? 10 / 11 : 11 / 10; + setWorldHeight(config.height, math.multiply(config.height, dir)); + updateWorldOptions(); + } + } checkFitWorld(); }) @@ -2609,6 +2614,8 @@ function saveScreenshot() { drawScale(false); } +const rateLimits = {}; + function toast(msg) { let div = document.createElement("div"); div.innerHTML = msg; @@ -2619,4 +2626,13 @@ function toast(msg) { setTimeout(() => { document.body.removeChild(div); }, 5000) +} + +function toastRateLimit(msg, key, delay) { + if (!rateLimits[key]) { + toast(msg); + rateLimits[key] = setTimeout(() => { + delete rateLimits[key] + }, delay); + } } \ No newline at end of file