add transition to queue track list

This commit is contained in:
geoffrey45 2022-08-12 12:49:33 +03:00
parent 59905f7afe
commit a32d8fe66c
8 changed files with 66 additions and 32 deletions

View File

@ -1,7 +1,6 @@
.now-playing-track-indicator { .now-playing-track-indicator {
background-image: url(../../assets/icons/playing.gif); background-image: url(../../assets/icons/playing.gif);
transition: all 0.3s ease-in-out;
height: 2rem; height: 2rem;
width: 2rem; width: 2rem;
border-radius: 50%; border-radius: 50%;

View File

@ -1,4 +1,8 @@
// paddings // paddings
.pad-smaller {
padding: $smaller;
}
.pad-small { .pad-small {
padding: $small; padding: $small;
} }

View File

@ -92,22 +92,26 @@ function updateQueue(track: Track) {
switch (routename) { switch (routename) {
case "FolderView": case "FolderView":
queue.playFromFolder(props.path, props.tracks); queue.playFromFolder(props.path || "", props.tracks);
queue.play(index); queue.play(index);
break; break;
case "AlbumView": case "AlbumView":
const tindex = album.tracks.findIndex((t) => t.trackid === track.trackid); const tindex = album.tracks.findIndex((t) => t.trackid === track.trackid);
queue.playFromAlbum( queue.playFromAlbum(
track.album, track.album || "",
track.albumartist, track.albumartist || "",
track.albumhash, track.albumhash || "",
album.tracks album.tracks
); );
queue.play(tindex); queue.play(tindex);
break; break;
case "PlaylistView": case "PlaylistView":
queue.playFromPlaylist(props.pname, props.playlistid, props.tracks); queue.playFromPlaylist(
props.pname || "",
props.playlistid || "",
props.tracks
);
queue.play(index); queue.play(index);
break; break;
} }

View File

@ -4,19 +4,21 @@
<UpNext :next="queue.tracklist[queue.next]" :playNext="queue.playNext" /> <UpNext :next="queue.tracklist[queue.next]" :playNext="queue.playNext" />
<div class="scrollable-r bg-black rounded"> <div class="scrollable-r bg-black rounded">
<QueueActions /> <QueueActions />
<div <div class="inner">
class="inner" <TransitionGroup
@mouseenter="setMouseOver(true)" name="queuelist"
@mouseleave="setMouseOver(false)" @mouseenter="setMouseOver(true)"
> @mouseleave="setMouseOver(false)"
<TrackItem >
v-for="(t, index) in queue.tracklist" <TrackItem
:key="t.trackid" v-for="(t, index) in queue.tracklist"
:track="t" :key="t.trackid"
@playThis="queue.play(index)" :track="t"
:isCurrent="index === queue.current" @playThis="queue.play(index)"
:isPlaying="queue.playing" :isCurrent="index === queue.current"
/> :isPlaying="queue.playing"
/>
</TransitionGroup>
</div> </div>
</div> </div>
<PlayingFrom :from="queue.from" /> <PlayingFrom :from="queue.from" />
@ -45,11 +47,30 @@ function setMouseOver(val: boolean) {
onUpdated(() => { onUpdated(() => {
if (mouseover.value) return; if (mouseover.value) return;
focusElem("currentInQueue"); setTimeout(() => {
focusElem("currentInQueue");
}, 1000);
}); });
</script> </script>
<style lang="scss"> <style lang="scss">
.queuelist-move, /* apply transition to moving elements */
.queuelist-enter-active {
transition: all 0.5s ease-in-out;
}
.queuelist-enter-from,
.queuelist-leave-to {
opacity: 0;
}
/* ensure leaving items are taken out of layout flow so that moving
animations can be calculated correctly. */
.queuelist-leave-active {
transition: none;
position: absolute;
}
.up-next { .up-next {
overflow: hidden; overflow: hidden;
height: 100%; height: 100%;

View File

@ -114,7 +114,7 @@ const showContextMenu = (e: Event) => {
const props = defineProps<{ const props = defineProps<{
track: Track; track: Track;
index: Number; index?: number;
isPlaying: Boolean; isPlaying: Boolean;
isCurrent: Boolean; isCurrent: Boolean;
isHighlighted: Boolean; isHighlighted: Boolean;

View File

@ -10,12 +10,8 @@
]" ]"
@contextmenu="showContextMenu" @contextmenu="showContextMenu"
> >
<div <div class="album-art">
class="album-art image rounded" <img :src="paths.images.thumb + track.image" alt="" class="rounded" />
:style="{
backgroundImage: `url(&quot;${imguri + props.track.image}&quot;)`,
}"
>
<div <div
class="now-playing-track-indicator image" class="now-playing-track-indicator image"
v-if="props.isCurrent" v-if="props.isCurrent"
@ -120,10 +116,17 @@ const playThis = (track: Track) => {
align-items: center; align-items: center;
justify-content: center; justify-content: center;
margin-right: $small;
position: relative;
.now-playing-track-indicator {
position: absolute;
}
}
img {
width: 3rem; width: 3rem;
height: 3rem; height: 3rem;
margin: 0 0.5rem 0 0;
background-image: url(../../assets/images/null.webp);
} }
.title { .title {

View File

@ -192,7 +192,7 @@ export default defineStore("Queue", {
this.from = <fromFolder>{ this.from = <fromFolder>{
type: FromOptions.folder, type: FromOptions.folder,
path: fpath, path: fpath,
name: fpath.split("/").splice(-1).join(""), name: fpath?.split("/").splice(-1).join(""),
}; };
this.setNewQueue(tracks); this.setNewQueue(tracks);
}, },

View File

@ -3,8 +3,11 @@
* @param seconds The seconds to convert * @param seconds The seconds to convert
* @param long Whether to provide the time in the long format * @param long Whether to provide the time in the long format
*/ */
export default function formatSeconds(seconds: number, long?: boolean) { export default function formatSeconds(
if (seconds == undefined) { seconds: number | undefined,
long?: boolean
) {
if (seconds === undefined) {
return "00:00"; return "00:00";
} }