fix(lyrics): resolve scrolling issue in ExpandedPlayer

- Fix reset effect to track actual content changes instead of array
  reference, preventing constant lastScrolledIndex resets in Svelte 5
- Add min-height: 0 to lyrics-container for proper flex height calculation
This commit is contained in:
vicrodh committed 2026-01-11 01:35:12 -06:00
1 parent e1ee5215ec
commit fd178b8643
2 files changed
+9 -4

No files matched your search

+1 -1
View File
@@ -674,7 +674,7 @@
.lyrics-container {
flex: 1;
overflow: hidden;
min-height: 0; /* Critical for flex child to allow shrinking */
max-height: calc(100vh - 160px);
mask-image: linear-gradient(
to bottom,
+8 -3
View File
@@ -31,6 +31,7 @@
let container: HTMLDivElement | null = null;
let lastScrolledIndex = -1;
let lastLyricsKey = '';
// Calculate opacity based on distance from active line
function getLineOpacity(index: number, active: number): number {
@@ -102,10 +103,14 @@
});
// Reset scroll tracking when lyrics change (new track)
// Use first line text as key to detect actual content change, not just array reference
$effect(() => {
// This effect only cares about lines array identity changing
void lines;
lastScrolledIndex = -1;
const newKey = lines.length > 0 ? `${lines.length}-${lines[0].text}` : '';
if (newKey !== lastLyricsKey) {
console.log('[LyricsLines] Lyrics content changed, resetting scroll tracking');
lastLyricsKey = newKey;
lastScrolledIndex = -1;
}
});
</script>