Home

dev / openkara

publicthedavidweng/OpenKara· sync paused
Overview Code History Branches Pull requestsIssuesInsights
main
HomeOverview Code PRsIssues

fix(lyrics): stabilize scroll follow across ambience, layout, and resize (#214)

2 months ago

6dbefb1
Authored
Davy7/25/2026, 6:10:58 PM
Fixes three recurring lyrics-scroll glitches that all live in the standard
lyrics follow path (#200, #201, #202).

#200 PlaybackStage rendered LyricsPanel in two structurally different slots
of a ternary: when the async cover-art backdrop resolved mid-song, the
top-level child type changed and React remounted LyricsPanel, clearing the
line-runtime springs (gather replay) and forcing scrollTop=0. Keep LyricsPanel
in one stable, keyed slot and render the ambience backdrop as an
absolutely-positioned sibling behind it; the CdgCanvas <-> LyricsPanel switch
stays a genuine media switch, not driven by async cover load.

#201 The rAF engine effect re-runs on lyricsFontStep / layoutVersion /
presentation changes and unconditionally reset scrollTop to 0, so using the
font control or Romanize toggle mid-song flew the lyrics to the top and
scrolled back down. Gate the reset-to-top on a genuine song change; on a
layout/font/romanize change, leave the viewport put and request an explicit
resume so the next frame snaps directly to the recomputed centered target for
the current active line.

#202 Standard mode had no ResizeObserver, so resizing the window / toggling
the sidebar while a line was held left the active line mis-centered until the
next line change. Observe the scroll viewport (mirroring the audience paging
hook) and, when follow is locked, re-center the current active line and snap;
skip while the user-scroll guard is active and debounce continuous resizes.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>

Parenta09a3f0

4 files changed
  • src/components/Playback/PlaybackStage.test.tsx+82−1
  • src/components/Playback/PlaybackStage.tsx+32−19
  • src/hooks/use-lyrics-engine.test.tsx+187−0
  • src/hooks/use-lyrics-engine.ts+138−13