From 6ec57e5702d3d6aeb8e4d9e569c8b8d0b7ffcdd5 Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Sun, 11 Jan 2026 01:23:50 -0600 Subject: [PATCH] debug: add scroll logging and make prevActiveIndex reactive --- src/lib/components/lyrics/LyricsLines.svelte | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/lib/components/lyrics/LyricsLines.svelte b/src/lib/components/lyrics/LyricsLines.svelte index 8d172b47f..8c6a72b91 100644 --- a/src/lib/components/lyrics/LyricsLines.svelte +++ b/src/lib/components/lyrics/LyricsLines.svelte @@ -30,13 +30,8 @@ }: Props = $props(); let container: HTMLDivElement | null = null; - let prevActiveIndex = -1; - let hasInitialSync = false; - - // Debug logging - $effect(() => { - console.log('[LyricsLines] Props:', { linesCount: lines.length, activeIndex, activeProgress: activeProgress.toFixed(2), isSynced, immersive }); - }); + let prevActiveIndex = $state(-1); + let hasInitialSync = $state(false); // Calculate opacity based on distance from active line function getLineOpacity(index: number, active: number): number { @@ -76,12 +71,12 @@ $effect(() => { if (scrollToActive && activeIndex >= 0 && activeIndex !== prevActiveIndex) { // Determine if we need instant scroll (catch-up sync) - // - First sync after lyrics load (hasInitialSync is false and activeIndex > 0) - // - Jump of more than 2 lines (user seeked or lyrics catching up) const needsInstantSync = !hasInitialSync && activeIndex > 0; const isLargeJump = prevActiveIndex >= 0 && Math.abs(activeIndex - prevActiveIndex) > 2; const useInstant = needsInstantSync || isLargeJump; + console.log('[LyricsLines] Scrolling to line', activeIndex, { prevActiveIndex, useInstant, hasInitialSync }); + if (!hasInitialSync && activeIndex >= 0) { hasInitialSync = true; }