diff --git a/SUMMARIES.md b/SUMMARIES.md index f9dad52..ba1f22e 100644 --- a/SUMMARIES.md +++ b/SUMMARIES.md @@ -333,3 +333,35 @@ Added `popSnap: number` (ms) to `StyleState` and `DEFAULT_STYLE` (default: 150ms ### BG color scope fix — fullscreen root no longer inherits bgColor The fullscreen root `
` had `style={isFullscreen ? { backgroundColor: effectiveBg } : undefined}`. This painted the entire fullscreen container (including toolbar, controls, album panel) with the user's BG color. The BG color is already applied correctly on the inner lyrics area div (`backgroundColor: effectiveBg` at line ~1804). Removed the root-level style entirely (`style={undefined}`). + +--- + +### Karaoke scroll jitter — root cause and fix + +**Root cause (windowed rendering):** `renderKaraokeStyle`, `renderGlowStyle`, and `renderBlurStyle` each used a `window = 3` slice (`lines.slice(activeLine-3, activeLine+4)`). Because the active line was always at index 3 within this window, its `offsetTop` was effectively constant (~3 × lineHeight) regardless of which line was active. The `translateY` formula `containerHeight/2 − offsetTop − lineHeight/2` therefore produced the same value on every line transition — no scroll animation occurred and lines appeared to "jump" into place. + +**Fix:** All three windowed render functions now iterate over **all lines** (`lines.map(...)`). Lines with `dist > 5` from the active line get `opacity: 0`; lines with `dist > 4` in blur mode skip the expensive `blur()` filter. The inner scroll div still uses `overflow: hidden` on its container, so only nearby lines are visible. With all lines in the DOM, `offsetTop` grows monotonically as `activeLine` advances, and the CSS `transition: transform 0.35s cubic-bezier(0.33, 1, 0.68, 1)` on the scroll div animates a true smooth vertical scroll. + +**Secondary fix — translateY bypasses React state:** `translateY` was moved from `useState` to a direct DOM write in `useLayoutEffect` via `scrollDivRef.current.style.transform`. This eliminates the two-render sequence on line changes (content update → state update → second render) that could cause the transition to be interrupted. `translateYRef` tracks the current value for use by `handleRecenter` and the `scaleX`/`scaleY` deps in the same effect. + +--- + +### Glow slider — configurable glow radius + +Added `glowSize: number` to `StyleState` and `DEFAULT_STYLE` (default: 8px). A **Glow** slider (2–24px, step 1px) appears in StylePicker when `visualStyle === 'glow'`. Required passing `visualStyle` as a new optional prop to `StylePicker`. The glow filter in `renderGlowStyle` uses `glowSize` for the inner shadow and `glowSize * 2` for the wider outer shadow: `` `drop-shadow(0 0 ${glowSize}px ${color}cc) drop-shadow(0 0 ${glowSize*2}px ${color}66)` ``. + +--- + +### Smooth size transition between active and adjacent lines + +**Problem:** The active line used a different `fontSize` multiplier (e.g. `fontSize * 1.05`) than inactive lines (`fontSize * 0.85`), causing an instant size jump on each line transition with no animation. + +**Why font-size transition wasn't used:** CSS `font-size` transitions cause layout reflow on every frame, which would desync the scroll position (the `useLayoutEffect` measures `offsetTop` based on the final layout, but the font-size is still mid-animation, so lines aren't at their measured positions yet). + +**Fix:** All three render functions (`renderKaraokeStyle`, `renderGlowStyle`, `renderBlurStyle`) now use a uniform base `fontSize` for all line divs in layout. Visual size is controlled via `transform: scale()` per line based on distance from active: +- `dist = 0` (active): `scale(1.0)` +- `dist = 1`: `scale(0.88)` +- `dist = 2`: `scale(0.82)` +- `dist ≥ 3`: `scale(0.78)`, opacity fades to 0 past dist 5 + +`transformOrigin` is set to match `textAlign` (`left center` / `center center` / `right center`). All lines get `transition: 'transform 0.35s ease-out, opacity 0.35s ease-out'` matching the scroll transition duration so both animate in sync. Since `transform` doesn't affect layout, `offsetTop` is stable and the scroll calculation remains correct. `KaraokeWord` now receives base `fontSize` (the wrapper div's scale handles visual enlargement). diff --git a/backend/static/index.html b/backend/static/index.html index 57b6eef..08db5b0 100644 --- a/backend/static/index.html +++ b/backend/static/index.html @@ -19,7 +19,7 @@ - + diff --git a/frontend/src/components/LyricsLivePreview.tsx b/frontend/src/components/LyricsLivePreview.tsx index f5fc0f9..8b7aa9d 100755 --- a/frontend/src/components/LyricsLivePreview.tsx +++ b/frontend/src/components/LyricsLivePreview.tsx @@ -422,6 +422,7 @@ interface StyleState { scaleY: number popScale: number popSnap: number + glowSize: number } const DEFAULT_STYLE: StyleState = { @@ -449,6 +450,7 @@ const DEFAULT_STYLE: StyleState = { scaleY: 1, popScale: 15, popSnap: 150, + glowSize: 8, } function StylePicker({ @@ -456,11 +458,13 @@ function StylePicker({ onChange, onReset, hasCoverArt, + visualStyle, }: { style: StyleState onChange: (patch: Partial) => void onReset: () => void hasCoverArt?: boolean + visualStyle?: string }) { return (
@@ -623,6 +627,16 @@ function StylePicker({ {style.popSnap}ms
)} + {visualStyle === 'glow' && ( +
+ Glow + onChange({ glowSize: +e.target.value })} + className="w-16 h-1.5 accent-brand-400" title="Glow radius (px)" /> + {style.glowSize}px +
+ )}
{/* Dynamic BG from album art — only shown when cover art is available */} {hasCoverArt && ( @@ -816,7 +830,7 @@ export default function LyricsLivePreview({ lrcText, audioUrl, stems, title, sty }, []) // Destructure for convenience - const { fontFamily, fontSize: baseFontSize, bgColor, textColor, highlightColor, wordHighlight, textAlign, lineSpacing, dynBg, karaokeMode, fontBold, strokeEnabled, strokeWidth, strokeColor, shadowEnabled, shadowBlur, shadowX, shadowY, shadowColor, shadowOpacity, scaleX, scaleY, popScale, popSnap } = style + const { fontFamily, fontSize: baseFontSize, bgColor, textColor, highlightColor, wordHighlight, textAlign, lineSpacing, dynBg, karaokeMode, fontBold, strokeEnabled, strokeWidth, strokeColor, shadowEnabled, shadowBlur, shadowX, shadowY, shadowColor, shadowOpacity, scaleX, scaleY, popScale, popSnap, glowSize } = style // fontSize is finalised after isFullscreen is available (declared below) // Passed to KaraokeWord so each word can render its own stroke/shadow behind-layer. @@ -901,9 +915,9 @@ export default function LyricsLivePreview({ lrcText, audioUrl, stems, title, sty const audioCtxRef = useRef(null) const gainRefs = useRef>({}) - const [translateY, setTranslateY] = useState(0) - const containerRef = useRef(null) + const scrollDivRef = useRef(null) + const translateYRef = useRef(0) const activeLineRef = useRef(null) const rafRef = useRef(null) const manualTimeRef = useRef(0) @@ -1177,18 +1191,22 @@ export default function LyricsLivePreview({ lrcText, audioUrl, stems, title, sty // The container has position:relative so children's offsetTop is measured // from the container, not a distant ancestor. useLayoutEffect(() => { - if (!activeLineRef.current || !containerRef.current) return + if (!activeLineRef.current || !containerRef.current || !scrollDivRef.current) return const container = containerRef.current const el = activeLineRef.current - setTranslateY(container.clientHeight / 2 - el.offsetTop - el.offsetHeight / 2) - }, [activeLine]) + const ty = container.clientHeight / 2 - el.offsetTop - el.offsetHeight / 2 + translateYRef.current = ty + scrollDivRef.current.style.transform = `translateY(${ty}px) scaleX(${scaleX}) scaleY(${scaleY})` + }, [activeLine, scaleX, scaleY]) // ── Recenter active line ────────────────────────────────────────────────── function handleRecenter() { - if (!activeLineRef.current || !containerRef.current) return + if (!activeLineRef.current || !containerRef.current || !scrollDivRef.current) return const container = containerRef.current const el = activeLineRef.current - setTranslateY(container.clientHeight / 2 - el.offsetTop - el.offsetHeight / 2) + const ty = container.clientHeight / 2 - el.offsetTop - el.offsetHeight / 2 + translateYRef.current = ty + scrollDivRef.current.style.transform = `translateY(${ty}px) scaleX(${scaleX}) scaleY(${scaleY})` } // ── Controls ────────────────────────────────────────────────────────────── @@ -1453,18 +1471,16 @@ export default function LyricsLivePreview({ lrcText, audioUrl, stems, title, sty function renderKaraokeStyle() { if (lines.length === 0) return

No lyrics

- const window = 3 - const start = Math.max(0, activeLine - window) - const end = Math.min(lines.length - 1, activeLine + window + 1) - const visible = lines.slice(start, end + 1) + const lineOrigin = textAlign === 'left' ? 'left center' : textAlign === 'right' ? 'right center' : 'center center' return ( <> - {visible.map((line, vi) => { - const i = start + vi + {lines.map((line, i) => { const active = i === activeLine const past = i < activeLine + const dist = Math.abs(i - activeLine) const nextLineTime = lines[i + 1]?.time + const scale = active ? 1.0 : dist === 1 ? 0.88 : dist === 2 ? 0.82 : 0.78 if (!active) { return ( @@ -1472,11 +1488,13 @@ export default function LyricsLivePreview({ lrcText, audioUrl, stems, title, sty key={i} style={{ textAlign, - padding: '0.3em 0.75em', - fontSize: fontSize * 0.85, - lineHeight: lineSpacing, - opacity: past ? 0.55 : 0.25, - transition: 'opacity 0.3s', + padding: '0.4em 0.75em', + fontSize, + lineHeight: lineSpacing, + opacity: dist > 5 ? 0 : (past ? 0.55 : 0.25), + transform: `scale(${scale})`, + transformOrigin: lineOrigin, + transition: 'transform 0.35s ease-out, opacity 0.35s ease-out', }} > @@ -1506,9 +1524,12 @@ export default function LyricsLivePreview({ lrcText, audioUrl, stems, title, sty ref={(el) => { activeLineRef.current = el }} style={{ textAlign, - padding: '0.4em 0.75em', - fontSize: fontSize * 1.05, - lineHeight: lineSpacing, + padding: '0.4em 0.75em', + fontSize, + lineHeight: lineSpacing, + transform: 'scale(1)', + transformOrigin: lineOrigin, + transition: 'transform 0.35s ease-out', }} > @@ -1526,7 +1547,7 @@ export default function LyricsLivePreview({ lrcText, audioUrl, stems, title, sty done={done} bright={activeBright} dim={activeDim} - fontSize={fontSize * 1.05} + fontSize={fontSize} isWordEnd={w.isWordEnd} elRef={wi === activeWordIdx ? activeWordSpanRef : undefined} isActive={wi === activeWordIdx} @@ -1567,18 +1588,16 @@ export default function LyricsLivePreview({ lrcText, audioUrl, stems, title, sty function renderGlowStyle() { if (lines.length === 0) return

No lyrics

- const window = 3 - const start = Math.max(0, activeLine - window) - const end = Math.min(lines.length - 1, activeLine + window + 1) - const visible = lines.slice(start, end + 1) + const lineOrigin = textAlign === 'left' ? 'left center' : textAlign === 'right' ? 'right center' : 'center center' return ( <> - {visible.map((line, vi) => { - const i = start + vi + {lines.map((line, i) => { const active = i === activeLine const past = i < activeLine + const dist = Math.abs(i - activeLine) const nextLineTime = lines[i + 1]?.time + const scale = active ? 1.0 : dist === 1 ? 0.88 : dist === 2 ? 0.82 : 0.78 if (!active) { return ( @@ -1586,11 +1605,13 @@ export default function LyricsLivePreview({ lrcText, audioUrl, stems, title, sty key={i} style={{ textAlign, - padding: '0.3em 0.75em', - fontSize: fontSize * 0.85, - lineHeight: lineSpacing, - opacity: past ? 0.5 : 0.2, - transition: 'opacity 0.4s ease', + padding: '0.4em 0.75em', + fontSize, + lineHeight: lineSpacing, + opacity: dist > 5 ? 0 : (past ? 0.5 : 0.2), + transform: `scale(${scale})`, + transformOrigin: lineOrigin, + transition: 'transform 0.35s ease-out, opacity 0.35s ease-out', }} > @@ -1618,11 +1639,13 @@ export default function LyricsLivePreview({ lrcText, audioUrl, stems, title, sty ref={(el) => { activeLineRef.current = el }} style={{ textAlign, - padding: '0.4em 0.75em', - fontSize: fontSize * 1.05, - lineHeight: lineSpacing, - filter: `drop-shadow(0 0 8px ${glowColor}cc) drop-shadow(0 0 16px ${glowColor}66)`, - transition: 'filter 0.3s ease', + padding: '0.4em 0.75em', + fontSize, + lineHeight: lineSpacing, + transform: 'scale(1)', + transformOrigin: lineOrigin, + filter: `drop-shadow(0 0 ${glowSize}px ${glowColor}cc) drop-shadow(0 0 ${glowSize * 2}px ${glowColor}66)`, + transition: 'transform 0.35s ease-out, filter 0.3s ease', }} > @@ -1640,7 +1663,7 @@ export default function LyricsLivePreview({ lrcText, audioUrl, stems, title, sty done={done} bright={glowColor} dim={dimColor} - fontSize={fontSize * 1.05} + fontSize={fontSize} isWordEnd={w.isWordEnd} elRef={wi === activeWordIdx ? activeWordSpanRef : undefined} isActive={wi === activeWordIdx} @@ -1681,19 +1704,16 @@ export default function LyricsLivePreview({ lrcText, audioUrl, stems, title, sty function renderBlurStyle() { if (lines.length === 0) return

No lyrics

- const window = 3 - const start = Math.max(0, activeLine - window) - const end = Math.min(lines.length - 1, activeLine + window + 1) - const visible = lines.slice(start, end + 1) + const lineOrigin = textAlign === 'left' ? 'left center' : textAlign === 'right' ? 'right center' : 'center center' return ( <> - {visible.map((line, vi) => { - const i = start + vi + {lines.map((line, i) => { const active = i === activeLine const past = i < activeLine const dist = Math.abs(i - activeLine) const nextLineTime = lines[i + 1]?.time + const scale = active ? 1.0 : dist === 1 ? 0.88 : dist === 2 ? 0.82 : 0.78 if (!active) { return ( @@ -1701,13 +1721,15 @@ export default function LyricsLivePreview({ lrcText, audioUrl, stems, title, sty key={i} style={{ textAlign, - padding: '0.3em 0.75em', - fontSize: fontSize * 0.88, - lineHeight: lineSpacing, - color: past ? (line.speaker ? getSpeakerColor(line.speaker) : wordHighlight) : textColor, - opacity: past ? 0.4 : 0.15, - filter: `blur(${dist * 1.5}px)`, - transition: 'opacity 0.4s ease, filter 0.4s ease', + padding: '0.4em 0.75em', + fontSize, + lineHeight: lineSpacing, + color: past ? (line.speaker ? getSpeakerColor(line.speaker) : wordHighlight) : textColor, + opacity: dist > 5 ? 0 : (past ? 0.4 : 0.15), + filter: dist > 4 ? 'none' : `blur(${dist * 1.5}px)`, + transform: `scale(${scale})`, + transformOrigin: lineOrigin, + transition: 'transform 0.35s ease-out, opacity 0.35s ease-out, filter 0.35s ease-out', }} > @@ -1726,11 +1748,13 @@ export default function LyricsLivePreview({ lrcText, audioUrl, stems, title, sty ref={(el) => { activeLineRef.current = el }} style={{ textAlign, - padding: '0.4em 0.75em', - fontSize: fontSize * 1.1, - lineHeight: lineSpacing, - filter: 'none', - transition: 'filter 0.4s ease', + padding: '0.4em 0.75em', + fontSize, + lineHeight: lineSpacing, + transform: 'scale(1)', + transformOrigin: lineOrigin, + filter: 'none', + transition: 'transform 0.35s ease-out, filter 0.35s ease-out', }} > @@ -1748,7 +1772,7 @@ export default function LyricsLivePreview({ lrcText, audioUrl, stems, title, sty done={done} bright={activeBright} dim={activeDim} - fontSize={fontSize * 1.1} + fontSize={fontSize} isWordEnd={w.isWordEnd} elRef={wi === activeWordIdx ? activeWordSpanRef : undefined} isActive={wi === activeWordIdx} @@ -1820,8 +1844,8 @@ export default function LyricsLivePreview({ lrcText, audioUrl, stems, title, sty } as any} >
- + {/* Speaker colour swatches — always shown so user knows if diarization is missing */}
Speakers