From 1f291d331c47f90b20a103862983457376b964fe Mon Sep 17 00:00:00 2001 From: Fen Dweller Date: Sat, 23 May 2020 14:42:22 -0400 Subject: [PATCH] Fix positioning when zooming in and out --- macrovision.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/macrovision.js b/macrovision.js index fcf54210..623a09c8 100644 --- a/macrovision.js +++ b/macrovision.js @@ -231,7 +231,12 @@ function snapRel(coords) { } function adjustAbs(coords, oldHeight, newHeight) { - return coords; + const ratio = math.divide(newHeight, oldHeight); + + const x = coords.x * ratio; + const y = coords.y * ratio; + + return { x: x, y: y}; } function pos2pix(coords) { @@ -2829,7 +2834,7 @@ function setWorldHeight(oldHeight, newHeight) { const element = document.querySelector("#entity-" + key); let newPosition; - if (!altHeld) { + if (altHeld) { newPosition = adjustAbs({ x: element.dataset.x, y: element.dataset.y }, oldHeight, config.height); } else { newPosition = { x: element.dataset.x, y: element.dataset.y };