diff --git a/src/pages/Playroom.vue b/src/pages/Playroom.vue index dd5c2dc..8acbb3c 100644 --- a/src/pages/Playroom.vue +++ b/src/pages/Playroom.vue @@ -41,7 +41,7 @@ const songInfo = useTemplateRef('songInfo') const playButton = useTemplateRef('playButton') const presentQueueListDialog = ref(false) -// const presentLyrics = ref(false) +const presentLyrics = ref(false) onMounted(async () => { Draggable.create(progressBarThumb.value, { @@ -55,7 +55,7 @@ onMounted(async () => { } }) thumbUpdate() - + setupEntranceAnimations() }) @@ -115,13 +115,13 @@ function setupEntranceAnimations() { if (controllerRef.value) { gsap.fromTo(controllerRef.value.children, { opacity: 0, y: 30, scale: 0.95 }, - { + { opacity: 1, y: 0, scale: 1, duration: 0.6, ease: "power2.out", stagger: 0.1 } ) } - + if (lyricsSection.value) { gsap.fromTo(lyricsSection.value, { opacity: 0, x: 50 }, @@ -147,7 +147,7 @@ function handlePlayPause() { function toggleShuffle() { playQueueStore.playMode.shuffle = !playQueueStore.playMode.shuffle playQueueStore.shuffleCurrent = false - + nextTick(() => { const shuffleBtn = playQueueDialog.value?.querySelector('.flex-1:first-child') as HTMLElement if (shuffleBtn) { @@ -167,7 +167,7 @@ function toggleRepeat() { }) } }) - + switch (playQueueStore.playMode.repeat) { case 'off': playQueueStore.playMode.repeat = 'all'; break case 'all': playQueueStore.playMode.repeat = 'single'; break @@ -177,17 +177,17 @@ function toggleRepeat() { function makePlayQueueListPresent() { presentQueueListDialog.value = true - + nextTick(() => { if (!playQueueDialogContainer.value || !playQueueDialog.value) return - + const tl = gsap.timeline() tl.to(playQueueDialogContainer.value, { backgroundColor: '#17171780', duration: 0.3, ease: 'power2.out' }).to(playQueueDialog.value, { x: 0, duration: 0.4, ease: 'power3.out' }, '<0.1') - + if (playQueueDialog.value.children.length > 0) { tl.fromTo(playQueueDialog.value.children, { opacity: 0, x: -20 }, @@ -201,7 +201,7 @@ function makePlayQueueListDismiss() { presentQueueListDialog.value = false return } - + const tl = gsap.timeline({ onComplete: () => { presentQueueListDialog.value = false @@ -213,19 +213,19 @@ function makePlayQueueListDismiss() { } } }) - + if (playQueueDialog.value.children.length > 0) { tl.to(playQueueDialog.value.children, { opacity: 0, x: -20, duration: 0.2, ease: 'power2.in', stagger: 0.03 }) } - + tl.to(playQueueDialog.value, { x: -384, duration: 0.3, ease: 'power2.in' }, playQueueDialog.value.children.length > 0 ? '<0.1' : '0') - .to(playQueueDialogContainer.value, { - backgroundColor: 'transparent', duration: 0.2, ease: 'power2.in' - }, '<') + .to(playQueueDialogContainer.value, { + backgroundColor: 'transparent', duration: 0.2, ease: 'power2.in' + }, '<') } function getCurrentTrack() { @@ -236,6 +236,70 @@ function getCurrentTrack() { } } +watch(() => [preferences.presentLyrics, getCurrentTrack().song.lyricUrl], (newValue, oldValue) => { + const [showLyrics, hasLyricUrl] = newValue + const [prevShowLyrics, _prevHasLyricUrl] = oldValue || [false, null] + + // Show lyrics when both conditions are met + if (showLyrics && hasLyricUrl) { + presentLyrics.value = true + nextTick(() => { + const tl = gsap.timeline() + tl.from(controllerRef.value, { + marginRight: '-40rem', + }).fromTo(lyricsSection.value, + { opacity: 0, x: 50, scale: 0.95 }, + { opacity: 1, x: 0, scale: 1, duration: 0.5, ease: "power2.out" }, + "-=0.3" + ) + }) + } + // Hide lyrics with different animations based on reason + else if (presentLyrics.value) { + let animationConfig + + // If lyrics were toggled off + if (prevShowLyrics && !showLyrics) { + animationConfig = { + opacity: 0, x: -50, scale: 0.95, + duration: 0.3, ease: "power2.in" + } + } + // If no lyrics available (song changed) + else if (!hasLyricUrl) { + animationConfig = { + opacity: 0, y: -20, scale: 0.98, + duration: 0.3, ease: "power1.in" + } + } + // Default animation + else { + animationConfig = { + opacity: 0, x: -50, + duration: 0.3, ease: "power2.in" + } + } + + const tl = gsap.timeline({ + onComplete: () => { + presentLyrics.value = false + } + }) + + tl.to(controllerRef.value, { + marginLeft: '44rem', + duration: 0.3, ease: "power2.out" + }) + .to(lyricsSection.value, animationConfig, '<') + .set(lyricsSection.value, { + opacity: 1, x: 0, y: 0, scale: 1 // Reset for next time + }) + .set(controllerRef.value, { + marginLeft: '0rem' // Reset for next time + }) + } +}, { immediate: true }) + onUnmounted(() => { }) @@ -247,7 +311,7 @@ watch(() => playQueueStore.currentIndex, () => { ease: "power2.inOut", yoyo: true, repeat: 1 }) } - + if (songInfo.value) { gsap.fromTo(songInfo.value, { opacity: 0, y: 10 }, @@ -267,15 +331,15 @@ watch(() => playQueueStore.currentIndex, () => {