From c06022876005a4acbde5b07faca1f9b45a34f660 Mon Sep 17 00:00:00 2001 From: Fen Dweller Date: Sun, 24 May 2020 08:43:14 -0400 Subject: [PATCH] Make panning look smoother The movements occur more rapidly, and transitions are disabled during the pan. --- macrovision.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/macrovision.js b/macrovision.js index 5b7b17e2..abcf73f7 100644 --- a/macrovision.js +++ b/macrovision.js @@ -1994,12 +1994,19 @@ document.addEventListener("DOMContentLoaded", () => { panning = true; panOffsetX = e.clientX; panOffsetY = e.clientY; + + Object.keys(entities).forEach(key => { + document.querySelector("#entity-" + key).classList.add("no-transition"); + }); } }); document.querySelector("#world").addEventListener("mouseup", e => { if (e.which == 2) { panning = false; + Object.keys(entities).forEach(key => { + document.querySelector("#entity-" + key).classList.remove("no-transition"); + }); } }); @@ -2008,10 +2015,16 @@ document.addEventListener("DOMContentLoaded", () => { panOffsetX = e.touches[0].clientX; panOffsetY = e.touches[0].clientY; e.preventDefault(); + Object.keys(entities).forEach(key => { + document.querySelector("#entity-" + key).classList.add("no-transition"); + }); }); document.querySelector("#world").addEventListener("touchend", e => { panning = false; + Object.keys(entities).forEach(key => { + document.querySelector("#entity-" + key).classList.remove("no-transition"); + }); }); document.querySelector("body").appendChild(testCtx.canvas); @@ -2867,7 +2880,7 @@ document.addEventListener("mousemove", (e) => { panOffsetY = e.clientY; updateSizes(); panReady = false; - setTimeout(() => panReady=true, 50); + setTimeout(() => panReady=true, 1000/120); } });