Align fullscreen lyrics across line wraps

This commit is contained in:
lucast committed 2026-09-30 05:18:08 +02:00
1 parent 4caa9135ee
commit bfaa4acb25
2 files changed
+16 -16

No files matched your search

+8 -3
View File
@@ -61,11 +61,16 @@ nuxtApp.hook("page:finish", () => {
@click="closeFullscreen()" @click="closeFullscreen()"
/> />
<div class="content-container" :class="{ lyrics: song.lyrics?.text }"> <div
<PlayerFullscreenTrackDisplay :show-buttons="mouseMovedRecently" /> class="content-container"
:class="{ lyrics: song.lyrics?.text }"
>
<PlayerFullscreenTrackDisplay
:show-buttons="mouseMovedRecently"
/>
<PlayerFullscreenLyricsDisplay <PlayerFullscreenLyricsDisplay
:animation-duration="0.2" :animation-duration="0.2"
:offset="200" :offset="250"
:show-scroll-bar="mouseMovedRecently" :show-scroll-bar="mouseMovedRecently"
/> />
</div> </div>
@@ -78,14 +78,13 @@ const transformY = computed(() => {
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
const firstLyric = lines[0] as HTMLElement let accumulatedHeight = 0
const activeLyric = lines[scrollActiveIndex.value] as HTMLElement for (let i = 0; i < scrollActiveIndex.value; i++) {
if (!firstLyric || !activeLyric) return 0 const line = lines[i] as HTMLElement | undefined
if (line) accumulatedHeight += line.getBoundingClientRect().height
}
return ( return -accumulatedHeight
firstLyric.getBoundingClientRect().top -
activeLyric.getBoundingClientRect().bottom
)
}) })
const manualOffset = ref(0) const manualOffset = ref(0)
@@ -112,8 +111,7 @@ const onWheel = (event: WheelEvent) => {
outerRef.value.offsetHeight, outerRef.value.offsetHeight,
window.innerHeight - 300, window.innerHeight - 300,
) )
const minTranslate = const minTranslate = -containerRef.value.scrollHeight + lowerViewportLimit
-containerRef.value.scrollHeight + lowerViewportLimit
manualOffset.value = Math.min( manualOffset.value = Math.min(
maxTranslate, maxTranslate,
@@ -132,10 +130,7 @@ const onLyricClick = (time: number) => {
const finalTransform = computed(() => { const finalTransform = computed(() => {
if (isScrolling.value) return manualOffset.value if (isScrolling.value) return manualOffset.value
const lyricsTop = top.value - topFadeExtension return transformY.value + offset + topFadeExtension
const guideY = import.meta.client ? window.innerHeight * 0.45 : 0
const laterLyricOffset = scrollActiveIndex.value > 0 ? 100 : 0
return transformY.value + guideY - lyricsTop + laterLyricOffset
}) })
</script> </script>