mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-04 20:43:04 +00:00
feat: use @vueuse/useVirtualList on sidebar queue
This commit is contained in:
@@ -2,18 +2,20 @@
|
|||||||
<QueueActions />
|
<QueueActions />
|
||||||
<div
|
<div
|
||||||
class="scrollable-r"
|
class="scrollable-r"
|
||||||
|
v-bind="containerProps"
|
||||||
|
style="height: 100%"
|
||||||
@mouseover="mouseover = true"
|
@mouseover="mouseover = true"
|
||||||
@mouseout="mouseover = false"
|
@mouseout="mouseover = false"
|
||||||
>
|
>
|
||||||
<div class="inner">
|
<div class="inner" v-bind="wrapperProps">
|
||||||
<TrackItem
|
<TrackItem
|
||||||
v-for="(t, index) in queue.tracklist"
|
style="height: 64px"
|
||||||
:key="index"
|
v-for="(t, index) in tracks"
|
||||||
:track="t"
|
:key="t.index"
|
||||||
|
:track="t.data"
|
||||||
:index="index"
|
:index="index"
|
||||||
:isPlaying="queue.playing"
|
:isPlaying="queue.playing"
|
||||||
:isHighlighted="false"
|
:isCurrent="t.index === queue.currentindex"
|
||||||
:isCurrent="index === queue.currentindex"
|
|
||||||
:isQueueTrack="true"
|
:isQueueTrack="true"
|
||||||
@PlayThis="playFromQueue(index)"
|
@PlayThis="playFromQueue(index)"
|
||||||
/>
|
/>
|
||||||
@@ -22,10 +24,11 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onUpdated, ref } from "vue";
|
import { computed, ref, onMounted } from "vue";
|
||||||
|
import { useVirtualList } from "@vueuse/core";
|
||||||
|
|
||||||
|
// import { focusElem } from "@/utils";
|
||||||
import useQStore from "@/stores/queue";
|
import useQStore from "@/stores/queue";
|
||||||
import { focusElem } from "@/utils";
|
|
||||||
|
|
||||||
import TrackItem from "../shared/TrackItem.vue";
|
import TrackItem from "../shared/TrackItem.vue";
|
||||||
import QueueActions from "./Queue/QueueActions.vue";
|
import QueueActions from "./Queue/QueueActions.vue";
|
||||||
@@ -37,13 +40,23 @@ function playFromQueue(index: number) {
|
|||||||
queue.play(index);
|
queue.play(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
onUpdated(() => {
|
const source = computed(() => queue.tracklist);
|
||||||
if (mouseover.value) return;
|
|
||||||
|
|
||||||
setTimeout(() => {
|
const {
|
||||||
focusElem("currentInQueue");
|
list: tracks,
|
||||||
}, 1000);
|
containerProps,
|
||||||
|
wrapperProps,
|
||||||
|
scrollTo,
|
||||||
|
} = useVirtualList(source, {
|
||||||
|
itemHeight: 64,
|
||||||
|
overscan: 10,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
scrollTo(queue.currentindex);
|
||||||
|
});
|
||||||
|
|
||||||
|
// TODO: Handle focusing current track on song end
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
|||||||
@@ -11,7 +11,11 @@
|
|||||||
@contextmenu.prevent="showMenu"
|
@contextmenu.prevent="showMenu"
|
||||||
>
|
>
|
||||||
<div class="album-art">
|
<div class="album-art">
|
||||||
<img :src="paths.images.thumb.small + track.image" alt="" class="rounded-sm" />
|
<img
|
||||||
|
:src="paths.images.thumb.small + track.image"
|
||||||
|
alt=""
|
||||||
|
class="rounded-sm"
|
||||||
|
/>
|
||||||
<div
|
<div
|
||||||
class="now-playing-track-indicator image"
|
class="now-playing-track-indicator image"
|
||||||
v-if="isCurrent"
|
v-if="isCurrent"
|
||||||
@@ -73,7 +77,7 @@ const playThis = (track: Track) => {
|
|||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
.currentInQueue {
|
.currentInQueue {
|
||||||
background: linear-gradient(37deg, $gray4, $gray3, $gray3);
|
background-color: $gray4;
|
||||||
}
|
}
|
||||||
|
|
||||||
.contexton {
|
.contexton {
|
||||||
@@ -109,7 +113,7 @@ const playThis = (track: Track) => {
|
|||||||
transform: scale(1) translateY(0);
|
transform: scale(1) translateY(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
background: linear-gradient(37deg, $gray4, $gray3, $gray3);
|
background-color: $gray5;
|
||||||
}
|
}
|
||||||
|
|
||||||
hr {
|
hr {
|
||||||
|
|||||||
Reference in New Issue
Block a user