From fa725b2d56a5a377010b97102577c8946aa3edee Mon Sep 17 00:00:00 2001 From: mxdanger <32040254+mxdanger@users.noreply.github.com> Date: Mon, 9 May 2022 23:03:23 -0700 Subject: [PATCH] Added timeline slider scroll wheel incrementation --- web/_js/main.js | 2 -- web/_js/time.js | 19 ++++++++++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/web/_js/main.js b/web/_js/main.js index 9961af40..935f04f9 100644 --- a/web/_js/main.js +++ b/web/_js/main.js @@ -321,8 +321,6 @@ async function init() { zoom = Math.max(minZoom, Math.min(maxZoom, zoom)) applyZoom(x, y, zoom) - - e.preventDefault() }, { passive: true }) /*function setDesiredZoom(x, y, target){ diff --git a/web/_js/time.js b/web/_js/time.js index e466f705..3aa4c9ed 100644 --- a/web/_js/time.js +++ b/web/_js/time.js @@ -85,8 +85,21 @@ timelineSlider.max = variationsConfig[currentVariation].versions.length - 1 timelineSlider.value = currentPeriod timelineList.children[0].value = defaultPeriod -timelineSlider.addEventListener("input", (event) => { - updateTooltip(parseInt(event.target.value), currentVariation) +timelineSlider.addEventListener("input", (e) => timelineParser(e.target.value)) + +timelineSlider.addEventListener("wheel", function (e) { + if (e.deltaY < 0) { + this.valueAsNumber += 1; + timelineParser(this.value) + } else { + this.value -= 1; + timelineParser(this.value) + } + e.stopPropagation(); +}, { passive: true }) + +function timelineParser(value) { + updateTooltip(parseInt(value), currentVariation) clearTimeout(updateTimeout) updateTimeout = setTimeout(() => { updateTime(parseInt(timelineSlider.value), currentVariation) @@ -96,7 +109,7 @@ timelineSlider.addEventListener("input", (event) => { } }, 50) }, 25) -}) +} variantsEl.addEventListener("input", (event) => { updateTime(-1, event.target.value)