From 8eadee92624c2f71ffb0ab3f8d2c69e8cbe2af91 Mon Sep 17 00:00:00 2001 From: Fen Dweller Date: Sat, 4 Apr 2020 21:53:54 -0400 Subject: [PATCH] Add scroll buttons on the sides of the world --- macrovision.css | 22 ++++++++++++++++++++++ macrovision.html | 13 +++++++------ macrovision.js | 32 ++++++++++++++++++++++---------- 3 files changed, 51 insertions(+), 16 deletions(-) diff --git a/macrovision.css b/macrovision.css index 09b25035..cd34b224 100644 --- a/macrovision.css +++ b/macrovision.css @@ -696,4 +696,26 @@ i.far { #spawners-categories { font-size: 24pt; +} + +.scroll-button { + position: absolute; + height: 100%; + width: 50px; + font-size: 40px; + background: #ffffff33; + border: 0px; + z-index: 1; +} + +.scroll-button:active { + background: #ffffff66; +} + +#scroll-left { + left: 0%; +} + +#scroll-right { + right: 0%; } \ No newline at end of file diff --git a/macrovision.html b/macrovision.html index e074dc6e..67329722 100644 --- a/macrovision.html +++ b/macrovision.html @@ -104,12 +104,6 @@ -
- -
-
- -
@@ -217,6 +211,13 @@
+ +
diff --git a/macrovision.js b/macrovision.js index 6f23e4ad..a4d5c27a 100644 --- a/macrovision.js +++ b/macrovision.js @@ -22,6 +22,9 @@ let dragScaleHandle = null; let dragEntityScale = 1; let dragEntityScaleHandle = null; +let scrollDirection = 0; +let scrollHandle = null; + let worldSizeDirty = false; @@ -1302,6 +1305,14 @@ function setHelpDate() { } } +function doScroll() { + document.querySelectorAll(".entity-box").forEach(element => { + element.dataset.x = parseFloat(element.dataset.x) + scrollDirection/180; + }); + updateSizes(); + scrollDirection *= 1.05; +} + document.addEventListener("DOMContentLoaded", () => { prepareMenu(); prepareEntities(); @@ -1609,18 +1620,19 @@ document.addEventListener("DOMContentLoaded", () => { arrangeEntities(order); }); - document.querySelector("#options-world-scroll-left").addEventListener("click", () => { - document.querySelectorAll(".entity-box").forEach(element => { - element.dataset.x = parseFloat(element.dataset.x) + 0.1; - }); - updateSizes(); + document.querySelector("#scroll-left").addEventListener("mousedown", () => { + scrollDirection = -1; + scrollHandle = setInterval(doScroll, 1000/20); }); - document.querySelector("#options-world-scroll-right").addEventListener("click", () => { - document.querySelectorAll(".entity-box").forEach(element => { - element.dataset.x = parseFloat(element.dataset.x) - 0.1; - }); - updateSizes(); + document.querySelector("#scroll-right").addEventListener("mousedown", () => { + scrollDirection = 1; + scrollHandle = setInterval(doScroll, 1000/20); + }); + + document.addEventListener("mouseup", () => { + clearInterval(scrollHandle); + scrollHandle = null; }); document.querySelector("#options-world-fit").addEventListener("click", () => fitWorld(true));