Refresh lyrics position on open

This commit is contained in:
lucast committed 2026-10-05 01:10:53 +02:00
1 parent bdfa76f993
commit 45ae19149f
2 files changed
+14 -1

No files matched your search

@@ -7,7 +7,7 @@ const { animationDuration, offset, showScrollBar } = defineProps<{
const song = useSong() const song = useSong()
const { fullscreen } = useFullscreen() const { fullscreen } = useFullscreen()
const { secondsPlayed } = usePlayer() const { secondsPlayed, refreshPosition } = usePlayer()
const debugView = useCookie("DEBUG_VIEW") const debugView = useCookie("DEBUG_VIEW")
const debugViewEnabled = computed(() => String(debugView.value ?? "") === "1") const debugViewEnabled = computed(() => String(debugView.value ?? "") === "1")
@@ -49,6 +49,7 @@ const scrollActiveIndex = computed(() => {
const height = ref<number>() const height = ref<number>()
const top = ref(0) const top = ref(0)
const syncedHeight = ref<number>() const syncedHeight = ref<number>()
const layoutVersion = ref(0)
const topFadeExtension = 75 const topFadeExtension = 75
const updateLyricsLayout = () => { const updateLyricsLayout = () => {
@@ -64,8 +65,15 @@ const updateLyricsLayout = () => {
watch( watch(
fullscreen, fullscreen,
async () => { async () => {
if (fullscreen.value) refreshPosition()
await nextTick() await nextTick()
updateLyricsLayout() updateLyricsLayout()
if (fullscreen.value) {
requestAnimationFrame(() => {
updateLyricsLayout()
layoutVersion.value++
})
}
}, },
{ immediate: true }, { immediate: true },
) )
@@ -77,6 +85,7 @@ const containerRef = useTemplateRef("container-ref")
const outerRef = useTemplateRef("outer-ref") const outerRef = useTemplateRef("outer-ref")
const transformY = computed(() => { const transformY = computed(() => {
layoutVersion.value
const lines = containerRef.value?.children const lines = containerRef.value?.children
if (scrollActiveIndex.value < 0 || !lines?.length) return 0 if (scrollActiveIndex.value < 0 || !lines?.length) return 0
+4
View File
@@ -48,6 +48,9 @@ export default defineNuxtPlugin((nuxtApp) => {
sound.value?.seek(value) sound.value?.seek(value)
}, },
}) })
const refreshPosition = () => {
tick.value++
}
const volume = computed<number>({ const volume = computed<number>({
get() { get() {
tick.value tick.value
@@ -404,6 +407,7 @@ export default defineNuxtPlugin((nuxtApp) => {
playAlbumAtIndex, playAlbumAtIndex,
getDuration, getDuration,
secondsPlayed, secondsPlayed,
refreshPosition,
duration, duration,
volume, volume,
queue, queue,