mirror of
https://github.com/zyllian/pipefall.git
synced 2025-01-18 03:32:55 -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>
|
<p>
|
||||||
<label>one in <input type="number" min="0" value="10" id="random-chance"> chance of playing every minute</label>
|
<label>one in <input type="number" min="0" value="10" id="random-chance"> chance of playing every minute</label>
|
||||||
</p>
|
</p>
|
||||||
|
<p>
|
||||||
|
<label><input type="range" id="volume" min="0" max="100" value="100"> volume</label>
|
||||||
|
</p>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|
9
index.js
9
index.js
|
@ -7,6 +7,7 @@
|
||||||
const now = document.getElementById("play-now");
|
const now = document.getElementById("play-now");
|
||||||
const playAtRandom = document.getElementById("play-at-random");
|
const playAtRandom = document.getElementById("play-at-random");
|
||||||
const randomChance = document.getElementById("random-chance");
|
const randomChance = document.getElementById("random-chance");
|
||||||
|
const volume = document.getElementById("volume");
|
||||||
|
|
||||||
playAtRandom.checked = false;
|
playAtRandom.checked = false;
|
||||||
|
|
||||||
|
@ -43,6 +44,13 @@
|
||||||
pipe.addEventListener("click", play);
|
pipe.addEventListener("click", play);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
volume.addEventListener("input", () => {
|
||||||
|
const v = volume.value / 100;
|
||||||
|
if (v >= 0 && v <= 1) {
|
||||||
|
pipefall.volume = v;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
function random(max) {
|
function random(max) {
|
||||||
return Math.floor(Math.random() * max);
|
return Math.floor(Math.random() * max);
|
||||||
}
|
}
|
||||||
|
@ -63,4 +71,5 @@
|
||||||
}
|
}
|
||||||
}, 1000);
|
}, 1000);
|
||||||
updateFalls();
|
updateFalls();
|
||||||
|
pipefall.volume = volume.value / 100;
|
||||||
})();
|
})();
|
||||||
|
|
Loading…
Add table
Reference in a new issue