fix(LyricsLines): use activeProgress as karaoke floor, lookahead as bonus

This commit is contained in:
Afonso Jorge Ramos committed 2026-05-12 17:58:16 +01:00
1 parent 4de657e2cd
commit f4f8fcf9bf
1 file changed
+11 -2
+11 -2
View File
@@ -139,11 +139,20 @@
// Inline style for the (single) active line. Computed reactively so any // Inline style for the (single) active line. Computed reactively so any
// change to lookahead / measurement state updates the karaoke position // change to lookahead / measurement state updates the karaoke position
// without restarting any animations. // without restarting any animations.
//
// Always uses activeProgress as the floor — lookahead just adds a small
// measured offset on top. Earlier this forced 0 on first paint, but if
// lookaheadEnabled ever fails to flip on (e.g. the line gets only a
// single notification before audio stops or a seek lands directly at
// p=1) the gradient would stay at 0 forever (= the line never goes
// through). Tracking activeProgress directly makes that failure mode
// graceful: even with no lookahead, the playhead still reflects audio.
const activeLineStyle = $derived.by(() => { const activeLineStyle = $derived.by(() => {
if (!isSynced || activeIndex < 0) return ''; if (!isSynced || activeIndex < 0) return '';
const base = Math.max(0, Math.min(1, activeProgress));
const prog = lookaheadEnabled const prog = lookaheadEnabled
? Math.max(0, Math.min(1, activeProgress + measuredBlockDelta)) ? Math.max(0, Math.min(1, base + measuredBlockDelta))
: 0; : base;
return `--line-progress: ${prog}; --block-interval: ${measuredBlockMs}ms`; return `--line-progress: ${prog}; --block-interval: ${measuredBlockMs}ms`;
}); });