From 1cecf52dfdc59d550da1442746458e5fe13778d6 Mon Sep 17 00:00:00 2001 From: Astrian Zheng Date: Wed, 28 May 2025 11:14:53 +1000 Subject: [PATCH] feat(Playroom): implement toggle functionality for more options dialog with animations --- src/pages/Playroom.vue | 50 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 4 deletions(-) diff --git a/src/pages/Playroom.vue b/src/pages/Playroom.vue index 3ad09b2..33f0608 100644 --- a/src/pages/Playroom.vue +++ b/src/pages/Playroom.vue @@ -44,6 +44,7 @@ const controllerRef = useTemplateRef('controllerRef') const lyricsSection = useTemplateRef('lyricsSection') const albumCover = useTemplateRef('albumCover') const songInfo = useTemplateRef('songInfo') +const moreOptionsDialog = useTemplateRef('moreOptionsDialog') const playButton = useTemplateRef('playButton') @@ -229,6 +230,47 @@ function getCurrentTrack() { } } +function toggleMoreOptions() { + if (!showMoreOptions.value) { + showMoreOptions.value = true + nextTick(() => { + if (moreOptionsDialog.value) { + const tl = gsap.timeline() + tl.fromTo(moreOptionsDialog.value, + { opacity: 0, scale: 0.9, y: 10 }, + { opacity: 1, scale: 1, y: 0, duration: 0.2, ease: "power2.out" } + ) + if (moreOptionsDialog.value.children[0]?.children) { + tl.fromTo(moreOptionsDialog.value.children[0].children, + { opacity: 0, x: -10 }, + { opacity: 1, x: 0, duration: 0.15, ease: "power2.out", stagger: 0.05 }, + "<0.1" + ) + } + } + }) + } else { + if (moreOptionsDialog.value) { + const tl = gsap.timeline({ + onComplete: () => { + showMoreOptions.value = false + } + }) + if (moreOptionsDialog.value.children[0]?.children) { + tl.to(moreOptionsDialog.value.children[0].children, + { opacity: 0, x: -10, duration: 0.1, ease: "power2.in", stagger: 0.02 } + ) + } + tl.to(moreOptionsDialog.value, + { opacity: 0, scale: 0.9, y: 10, duration: 0.15, ease: "power2.in" }, + moreOptionsDialog.value.children[0]?.children ? "<0.05" : "0" + ) + } else { + showMoreOptions.value = false + } + } +} + watch(() => [preferences.presentLyrics, getCurrentTrack().song.lyricUrl], (newValue, oldValue) => { const [showLyrics, hasLyricUrl] = newValue const [prevShowLyrics, _prevHasLyricUrl] = oldValue || [false, null] @@ -525,7 +567,7 @@ watch(() => playQueueStore.currentIndex, () => {