From b5334c76ccda5b76962338dbbb2c27017773d611 Mon Sep 17 00:00:00 2001 From: Fen Dweller Date: Tue, 2 Jun 2020 16:07:02 -0400 Subject: [PATCH] Fix things being dragged out of bounds on the first mousemove The site wasn't checking if the entity started in bounds until after one instance of movement. --- macrovision.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/macrovision.js b/macrovision.js index 55f246e2..b7322adb 100644 --- a/macrovision.js +++ b/macrovision.js @@ -604,6 +604,14 @@ function clickDown(target, x, y) { let entY = document.querySelector("#entities").getBoundingClientRect().y; dragOffsetX = x - rect.left + entX; dragOffsetY = y - rect.top + entY; + + x = x - dragOffsetX; + y = y - dragOffsetY; + if (x >= 0 && x <= canvasWidth && y >= 0 && y <= canvasHeight) { + movingInBounds = true; + } + + clickTimeout = setTimeout(() => { dragging = true }, 200) target.classList.add("no-transition"); }