Skip to content

Commit 598d7ff

Browse files
committed
more fixes to volume handling
1 parent 9486611 commit 598d7ff

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

lib/event_horizon_web/live/jukebox_live.ex

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,13 +322,15 @@ defmodule EventHorizonWeb.JukeboxLive do
322322
323323
const slider = this.el.querySelector('#jukebox-volume-slider');
324324
if (slider) {
325-
const onVolume = (e) => {
326-
const vol = parseInt(e.target.value, 10) / 100;
327-
e.target.style.setProperty("--vol", (vol * 100) + "%");
325+
const onVolume = () => {
326+
const vol = parseInt(slider.value, 10) / 100;
327+
slider.style.setProperty("--vol", (vol * 100) + "%");
328328
Object.values(this._audios).forEach(a => a.volume = vol);
329+
this.pushEvent("set_volume", {volume: parseInt(slider.value, 10)});
329330
};
330331
slider.addEventListener("input", onVolume);
331332
slider.addEventListener("change", onVolume);
333+
slider.addEventListener("touchmove", onVolume);
332334
}
333335
},
334336
updated() {
@@ -368,6 +370,10 @@ defmodule EventHorizonWeb.JukeboxLive do
368370
{:noreply, assign(socket, open: false)}
369371
end
370372

373+
def handle_event("set_volume", %{"volume" => vol}, socket) do
374+
{:noreply, assign(socket, volume: vol)}
375+
end
376+
371377
def handle_event("set_category", %{"cat" => cat}, socket) do
372378
category = String.to_existing_atom(cat)
373379
{:noreply, assign(socket, category: category)}

0 commit comments

Comments
 (0)