Extended synced lyrics fade

This commit is contained in:
lucast committed 2026-09-25 21:51:24 +02:00
1 parent 16e309c346
commit 30c7972647
2 files changed
+30 -11

No files matched your search

+4
View File
@@ -144,6 +144,10 @@ nuxtApp.hook("page:finish", () => {
& > * { & > * {
margin: initial; margin: initial;
} }
& > :deep(.synced-lyrics-container) {
max-height: none;
}
} }
} }
</style> </style>
@@ -47,21 +47,31 @@ const scrollActiveIndex = computed(() => {
}) })
const height = ref<number>() const height = ref<number>()
const top = ref(0)
const syncedHeight = ref<number>()
const updateLyricsLayout = () => {
const trackDisplay = document.querySelector(".track-display")
if (!trackDisplay) return
height.value = trackDisplay.clientHeight
top.value = trackDisplay.getBoundingClientRect().top
syncedHeight.value = window.innerHeight - top.value - 100
}
watch( watch(
fullscreen, fullscreen,
async () => { async () => {
await nextTick() await nextTick()
updateLyricsLayout()
const trackDisplay = document.querySelector(".track-display")
if (!trackDisplay) return
height.value = trackDisplay.clientHeight
}, },
{ immediate: true }, { immediate: true },
) )
onMounted(() => window.addEventListener("resize", updateLyricsLayout))
onUnmounted(() => window.removeEventListener("resize", updateLyricsLayout))
const transformY = computed(() => { const transformY = computed(() => {
if (activeIndex.value < 0) return 0 if (activeIndex.value < 0) return 0
@@ -96,8 +106,12 @@ const onWheel = (event: WheelEvent) => {
manualOffset.value -= delta manualOffset.value -= delta
const maxTranslate = offset const maxTranslate = offset
const lowerViewportLimit = Math.max(
outerRef.value.offsetHeight,
window.innerHeight - 300,
)
const minTranslate = const minTranslate =
-containerRef.value.scrollHeight + outerRef.value.offsetHeight -containerRef.value.scrollHeight + lowerViewportLimit
manualOffset.value = Math.min( manualOffset.value = Math.min(
maxTranslate, maxTranslate,
@@ -120,7 +134,8 @@ const finalTransform = computed(() => {
v-if="song && song.lyrics && song.lyrics.synced" v-if="song && song.lyrics && song.lyrics.synced"
class="synced-lyrics-container" class="synced-lyrics-container"
:style="{ :style="{
height: `${height}px`, height: `${syncedHeight}px`,
marginTop: `${top}px`,
}" }"
@wheel.prevent="onWheel" @wheel.prevent="onWheel"
> >
@@ -162,13 +177,13 @@ const finalTransform = computed(() => {
.synced-lyrics-container { .synced-lyrics-container {
position: relative; position: relative;
overflow: hidden; overflow: hidden;
align-self: start;
mask-image: linear-gradient( mask-image: linear-gradient(
to bottom,
transparent 0%, transparent 0%,
#000 15%, #000 15%,
#000, #000 calc(100% - 200px),
#000,
95%,
transparent 100% transparent 100%
); );
} }