use virtual scroll page layout in album page

This commit is contained in:
geoffrey45 2022-09-21 14:57:24 +03:00 committed by Mungai Njoroge
parent 703ea71514
commit 74ea700d93
3 changed files with 35 additions and 12 deletions

View File

@ -7,7 +7,7 @@
@scroll="handleScroll" @scroll="handleScroll"
> >
<div v-bind="wrapperProps"> <div v-bind="wrapperProps">
<div class="header rounded pad-sm" style="height: 64px"> <div class="header rounded" style="height: 64px">
<div <div
ref="header" ref="header"
:style="{ top: -headerHeight + 64 - 16 + 'px' }" :style="{ top: -headerHeight + 64 - 16 + 'px' }"
@ -18,12 +18,21 @@
</div> </div>
<SongItem <SongItem
style="height: 60px" style="height: 60px"
v-for="(t, index) in tracks" v-for="t in tracks"
:key="t.data.trackid" :key="t.data.trackid"
:track="t.data" :track="t.data"
:index="0" :index="
on_album_page
? t.data.track
: t.data.index !== undefined
? t.data.index + 1
: t.index + 1
"
:isPlaying="queue.playing" :isPlaying="queue.playing"
:isCurrent="queue.currentid == t.data.trackid" :isCurrent="queue.currentid == t.data.trackid"
@playThis="
updateQueue(t.data.index !== undefined ? t.data.index : t.index)
"
/> />
</div> </div>
</div> </div>
@ -40,6 +49,11 @@ import SongItem from "@/components/shared/SongItem.vue";
const props = defineProps<{ const props = defineProps<{
tracks: Track[]; tracks: Track[];
on_album_page?: boolean;
}>();
const emit = defineEmits<{
(e: "playFromPage", index: number): void;
}>(); }>();
const queue = useQStore(); const queue = useQStore();
@ -56,6 +70,10 @@ const {
overscan: 15, overscan: 15,
}); });
function updateQueue(index: number) {
emit("playFromPage", index);
}
function handleScroll(e: Event) { function handleScroll(e: Event) {
const scrollTop = (e.target as HTMLElement).scrollTop; const scrollTop = (e.target as HTMLElement).scrollTop;
@ -74,6 +92,7 @@ function handleScroll(e: Event) {
.header-content { .header-content {
position: absolute; position: absolute;
width: 100%;
} }
} }
} }

View File

@ -50,7 +50,7 @@ const source = computed(() => queue.tracklist);
// import { focusElem } from "@/utils"; // import { focusElem } from "@/utils";
</script> </script>
<style lang="scss"> <!-- <style lang="scss">
.queue-view { .queue-view {
} }
</style> </style> -->

View File

@ -1,12 +1,9 @@
<template> <template>
<Page> <Layout :tracks="album.tracks" @playFromPage="playFromAlbum">
<template #header> <template #header>
<Header :album="album.info" :bio="album.bio" /> <Header :album="album.info" :bio="album.bio" />
</template> </template>
<template #content> </Layout>
<Content :discs="album.discs" :copyright="album.info.copyright" />
</template>
</Page>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
@ -18,10 +15,11 @@ import {
} from "vue-router"; } from "vue-router";
import Header from "./Header.vue"; import Header from "./Header.vue";
import Content from "./Content.vue"; import Layout from "@/layouts/HeaderAndVList.vue";
import Page from "@/layouts/HeaderContentBottom.vue"; import useQueueStore from "@/stores/queue";
const album = useAStore(); const album = useAStore();
const queue = useQueueStore();
onBeforeRouteUpdate(async (to: RouteLocationNormalized) => { onBeforeRouteUpdate(async (to: RouteLocationNormalized) => {
await album await album
@ -34,4 +32,10 @@ onBeforeRouteLeave(() => {
album.resetQuery(); album.resetQuery();
}, 500); }, 500);
}); });
function playFromAlbum(index: number) {
const { title, artist, hash } = album.info;
queue.playFromAlbum(title, artist, hash, album.allTracks);
queue.play(index);
}
</script> </script>