Scroll current song into view when song changes
This commit is contained in:
parent
29103c1c8a
commit
25889df62e
1 changed files with 10 additions and 0 deletions
|
@ -25,6 +25,14 @@
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
const scrollCurrentSongIntoView = () => {
|
||||||
|
const hoveredSong = document.querySelector(".queue li:hover");
|
||||||
|
if (hoveredSong === null) {
|
||||||
|
const currentSong = document.querySelector(".queue li.playing");
|
||||||
|
currentSong.scrollIntoView({ block: "nearest" });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
htmx.onLoad(() => {
|
htmx.onLoad(() => {
|
||||||
const isReduced = window
|
const isReduced = window
|
||||||
.matchMedia("(prefers-reduced-motion: reduce)")
|
.matchMedia("(prefers-reduced-motion: reduce)")
|
||||||
|
@ -38,5 +46,7 @@ htmx.onLoad(() => {
|
||||||
body: JSON.stringify({from: event.oldIndex, to: event.newIndex}),
|
body: JSON.stringify({from: event.oldIndex, to: event.newIndex}),
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
scrollCurrentSongIntoView();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in a new issue