From c688fe434732614794cf9fa45c387a880720d3a7 Mon Sep 17 00:00:00 2001 From: zyl Date: Mon, 4 Nov 2024 10:30:57 -0800 Subject: [PATCH] add volume slider --- index.html | 3 +++ index.js | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/index.html b/index.html index 61252bd..11bc170 100644 --- a/index.html +++ b/index.html @@ -26,6 +26,9 @@

+

+ +

diff --git a/index.js b/index.js index c7e36d2..5cf570d 100644 --- a/index.js +++ b/index.js @@ -7,6 +7,7 @@ const now = document.getElementById("play-now"); const playAtRandom = document.getElementById("play-at-random"); const randomChance = document.getElementById("random-chance"); + const volume = document.getElementById("volume"); playAtRandom.checked = false; @@ -43,6 +44,13 @@ pipe.addEventListener("click", play); } + volume.addEventListener("input", () => { + const v = volume.value / 100; + if (v >= 0 && v <= 1) { + pipefall.volume = v; + } + }); + function random(max) { return Math.floor(Math.random() * max); } @@ -63,4 +71,5 @@ } }, 1000); updateFalls(); + pipefall.volume = volume.value / 100; })();