mirror of
https://github.com/zyllian/pipefall.git
synced 2025-01-17 19:22:48 -08:00
add volume slider
This commit is contained in:
parent
8572827797
commit
c688fe4347
2 changed files with 12 additions and 0 deletions
|
@ -26,6 +26,9 @@
|
|||
<p>
|
||||
<label>one in <input type="number" min="0" value="10" id="random-chance"> chance of playing every minute</label>
|
||||
</p>
|
||||
<p>
|
||||
<label><input type="range" id="volume" min="0" max="100" value="100"> volume</label>
|
||||
</p>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
9
index.js
9
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;
|
||||
})();
|
||||
|
|
Loading…
Add table
Reference in a new issue