Improvements to karaoke display.
This commit is contained in:
1 parent
e3704a1318
commit
d21bddd1d9
5 files changed
+400
-34
No files matched your search
@@ -1649,6 +1649,62 @@ This pre-hides all spans so the backward fill takes effect without the one-frame
|
||||
|
||||
---
|
||||
|
||||
### 2026-03-13 — Video Line mode fix: timed progressive reveal (ELRC syllables / LRC words)
|
||||
|
||||
**File:** `frontend/src/components/LyricsCanvas.tsx`
|
||||
|
||||
**Problem observed:** In Video **Line** layout mode, the full line rendered at once instead of revealing one timed unit at a time.
|
||||
|
||||
**Root cause:**
|
||||
- `updateScene(...)` treated `displayMode === 'line'` as a non-scroll single-unit mode.
|
||||
- On each line change it built one span with `spanText = activeLine.text`, then animated that single span.
|
||||
- Because only one span existed for the line, timing granularity from ELRC/LRC was never used in Line mode.
|
||||
|
||||
**Fix implemented:**
|
||||
1. Changed the progressive branch condition from `displayMode === 'scroll'` to:
|
||||
- `displayMode === 'scroll' || displayMode === 'line'`
|
||||
2. Line mode now uses the same progressive queued insertion model used by scroll mode (`videoLineUnits`, per-frame reveal when `unit.time <= currentTime`).
|
||||
3. Added auto granularity selection for Line mode:
|
||||
- If ELRC timed units (`line.words`) exist → reveal by **syllable** timing.
|
||||
- Else fallback to LRC-style **word** timing buckets.
|
||||
4. Kept the old one-unit-at-a-time branch only for explicit `displayMode === 'word'` and `displayMode === 'syllable'` modes.
|
||||
5. Updated type narrowing logic so TS correctly treats the non-progressive branch as `word|syllable` only.
|
||||
|
||||
**Result:**
|
||||
- Video **Line** mode now reveals text progressively according to available timing data instead of showing the entire line instantly.
|
||||
|
||||
---
|
||||
|
||||
### 2026-03-13 — Video Line mode UX fix: static centered line while revealing units
|
||||
|
||||
**File:** `frontend/src/components/LyricsCanvas.tsx`
|
||||
|
||||
**Problem:** After enabling timed Line mode reveal, the text position still shifted as units were inserted (line “grew” while revealing). Desired behavior is a static centered line with units being revealed in place.
|
||||
|
||||
**Root cause:**
|
||||
- The progressive queue inserted DOM nodes over time (`appendChild` per due unit).
|
||||
- Center alignment recalculated as content width grew, causing horizontal drift.
|
||||
|
||||
**Fix implemented:**
|
||||
1. Extended `SceneState.videoLineUnits` entries with `el: HTMLSpanElement | null` so each timed unit can reference a prebuilt DOM node.
|
||||
2. In `displayMode === 'line'`, prebuild the full line structure at line start:
|
||||
- syllable path: prebuild all word containers and all syllable spans
|
||||
- word path: prebuild all word spans
|
||||
- each prebuilt unit span starts with `visibility: hidden` (occupies layout width but not visible)
|
||||
3. On each timed reveal tick, for Line mode:
|
||||
- switch unit span to `visibility: visible`
|
||||
- animate that existing span in place
|
||||
4. Updated `animateSpan(...)` to preserve in-place layout for existing elements:
|
||||
- remembers original parent/next sibling
|
||||
- runs registry animation through a temporary container
|
||||
- re-inserts span back to its original position immediately
|
||||
|
||||
**Result:**
|
||||
- Line stays visually centered and static from the first frame.
|
||||
- Words/syllables reveal at LRC/ELRC timing without lateral recenter drift.
|
||||
|
||||
---
|
||||
|
||||
### 2026-03-13 — LyricsCanvas hardening pass (perf + lifecycle + TS typing)
|
||||
|
||||
**File:** `frontend/src/components/LyricsCanvas.tsx`
|
||||
@@ -1744,3 +1800,29 @@ This pre-hides all spans so the backward fill takes effect without the one-frame
|
||||
- `videoLineUnits: Array<{text,time,added,wordElIdx}>` — pending unit queue
|
||||
|
||||
**WIP sync:** Copied `LyricsCanvas.tsx` to `frontend-karaoke-wip/src/components/`.
|
||||
|
||||
---
|
||||
|
||||
### 2026-03-13 — Video mode fix: apply stroke/shadow effects on HTML overlay text
|
||||
|
||||
**File:** `frontend/src/components/LyricsCanvas.tsx`
|
||||
|
||||
**Problem:** Stroke and shadow controls worked in SVG-rendered styles, but had no visible effect in Video mode.
|
||||
|
||||
**Root cause:**
|
||||
- Video mode renders text in an HTML overlay (`<div>/<span>`), not Two.js SVG text nodes.
|
||||
- Existing stroke/shadow logic in `LyricsCanvas` was implemented through SVG stroke/filter application paths (`buildWordUnits`, deferred SVG filter passes), so video overlay spans never received equivalent CSS effects.
|
||||
|
||||
**Fix implemented:**
|
||||
1. Added `hexToRgba(hex, opacity)` helper in `LyricsCanvas.tsx` to convert hex + opacity to CSS `rgba(...)` for shadow color parity.
|
||||
2. In the Video branch of `updateScene(...)`, computed:
|
||||
- `strokeVal` from `style.strokeEnabled`, `style.strokeWidth`, `style.strokeColor`
|
||||
- `shadowVal` from `style.shadowEnabled`, `style.shadowX/Y`, `style.shadowBlur`, `style.shadowColor`, `style.shadowOpacity`
|
||||
3. Applied these styles to the video overlay container (`makeFlexDiv`) so overlay text inherits effects:
|
||||
- `-webkit-text-stroke`
|
||||
- `text-shadow`
|
||||
- `paint-order: stroke fill`
|
||||
4. Also applied the same styles directly to all unit spans created in video paths (scroll/line/word/syllable; static prebuilt and progressive-inserted spans) to ensure consistent rendering across browsers and dynamic insertion flows.
|
||||
|
||||
**Result:**
|
||||
- Stroke and shadow controls now affect Video mode text consistently, matching user expectations from other preview modes.
|
||||
@@ -19,8 +19,8 @@
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
||||
<meta name="apple-mobile-web-app-title" content="StemEngine" />
|
||||
<link rel="apple-touch-icon" href="/icon.svg" />
|
||||
<script type="module" crossorigin src="/assets/index-BhLWcOYu.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-B7gP-Fm-.css">
|
||||
<script type="module" crossorigin src="/assets/index-D7qgrvOb.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-7HDOX98b.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
|
||||
@@ -17,6 +17,10 @@ import {
|
||||
type VideoAnimStyle,
|
||||
type VideoTimingGranularity,
|
||||
} from '../utils/videoAnimations'
|
||||
import {
|
||||
VIDEO_TRANSITION_REGISTRY,
|
||||
type VideoLineTransition,
|
||||
} from '../utils/videoAnimations'
|
||||
|
||||
// ── Types re-exported from LyricsLivePreview ─────────────────────────────────
|
||||
// Import these from wherever they are defined in the project.
|
||||
@@ -67,6 +71,7 @@ export interface StyleState {
|
||||
videoAnimStyle: VideoAnimStyle
|
||||
videoGranularity: VideoTimingGranularity
|
||||
videoDisplayMode: 'scroll' | 'line' | 'word' | 'syllable'
|
||||
videoLineTransition: VideoLineTransition
|
||||
}
|
||||
|
||||
// ── Internal scene types ──────────────────────────────────────────────────────
|
||||
@@ -115,7 +120,7 @@ interface SceneState {
|
||||
// Progressive reveal state for video scroll mode
|
||||
videoFlexEl: HTMLDivElement | null
|
||||
videoWordEls: HTMLSpanElement[]
|
||||
videoLineUnits: Array<{ text: string; time: number; added: boolean; wordElIdx: number }>
|
||||
videoLineUnits: Array<{ text: string; time: number; added: boolean; wordElIdx: number; el: HTMLSpanElement | null }>
|
||||
lineWordGroups: Array<Array<{ text: string; startTime: number; syllables: Array<{ text: string; time: number }> }>>
|
||||
}
|
||||
|
||||
@@ -217,6 +222,14 @@ function lineStride(style: StyleState): number {
|
||||
return style.fontSize * style.lineSpacing * LINE_STRIDE_FACTOR
|
||||
}
|
||||
|
||||
function hexToRgba(hex: string, opacity: number): string {
|
||||
const safe = Math.max(0, Math.min(1, opacity))
|
||||
const r = parseInt(hex.slice(1, 3), 16)
|
||||
const g = parseInt(hex.slice(3, 5), 16)
|
||||
const b = parseInt(hex.slice(5, 7), 16)
|
||||
return `rgba(${r}, ${g}, ${b}, ${safe})`
|
||||
}
|
||||
|
||||
function getLineVisualTargets(
|
||||
visualStyle: LyricsVisualStyle,
|
||||
style: StyleState,
|
||||
@@ -894,8 +907,14 @@ function updateScene(
|
||||
// Video style: HTML overlay — handles scroll/line/word/syllable display modes
|
||||
if (visualStyle === 'video') {
|
||||
const displayMode = style.videoDisplayMode
|
||||
const strokeVal = style.strokeEnabled && style.strokeWidth > 0
|
||||
? `${style.strokeWidth}px ${style.strokeColor}`
|
||||
: '0 transparent'
|
||||
const shadowVal = style.shadowEnabled
|
||||
? `${style.shadowX}px ${style.shadowY}px ${style.shadowBlur}px ${hexToRgba(style.shadowColor, style.shadowOpacity)}`
|
||||
: 'none'
|
||||
|
||||
const makeFlexDiv = (): HTMLDivElement => {
|
||||
const makeFlexDiv = (lineColor: string): HTMLDivElement => {
|
||||
const justifyContent = style.textAlign === 'left' ? 'flex-start'
|
||||
: style.textAlign === 'right' ? 'flex-end'
|
||||
: 'center'
|
||||
@@ -908,27 +927,41 @@ function updateScene(
|
||||
`font-family:${style.fontFamily}`,
|
||||
`font-size:${style.fontSize}px`,
|
||||
`font-weight:${style.fontBold ? 700 : 400}`,
|
||||
`color:${style.textColor}`,
|
||||
`color:${lineColor}`,
|
||||
`-webkit-text-stroke:${strokeVal}`,
|
||||
'paint-order:stroke fill',
|
||||
`text-shadow:${shadowVal}`,
|
||||
'gap:0.3em',
|
||||
'overflow:hidden',
|
||||
].join(';')
|
||||
return d
|
||||
}
|
||||
|
||||
const animateSpan = (span: HTMLElement, animDef: typeof VIDEO_ANIM_REGISTRY[0]) => {
|
||||
const animateSpan = (
|
||||
span: HTMLElement,
|
||||
animDef: typeof VIDEO_ANIM_REGISTRY[0],
|
||||
lineColor: string,
|
||||
) => {
|
||||
// Animate a single span immediately (delay=0) by routing through a temp container
|
||||
// so the registry's animate() doesn't touch already-visible spans.
|
||||
const parent = span.parentElement
|
||||
const next = span.nextSibling
|
||||
span.dataset.delay = '0'
|
||||
const tmp = document.createElement('div')
|
||||
tmp.appendChild(span)
|
||||
const anims = animDef.animate(tmp, style.videoGranularity, {
|
||||
text: style.textColor, active: style.activeColor,
|
||||
text: lineColor,
|
||||
active: lineColor,
|
||||
})
|
||||
state.activeAnimations.push(...anims)
|
||||
if (parent) {
|
||||
if (next) parent.insertBefore(span, next)
|
||||
else parent.appendChild(span)
|
||||
}
|
||||
}
|
||||
|
||||
if (displayMode === 'scroll') {
|
||||
// ── Scroll mode: progressive word/syllable reveal ──
|
||||
if (displayMode === 'scroll' || displayMode === 'line') {
|
||||
// ── Scroll/Line modes: progressive timed reveal ──────────────────────
|
||||
// Spans are added to the DOM exactly when their timestamp arrives so
|
||||
// animation-delay quirks cannot cause all words to flash in at once.
|
||||
const lineChanged = newActiveIdx !== state.lastVideoLineIdx
|
||||
@@ -936,19 +969,43 @@ function updateScene(
|
||||
if (lineChanged) {
|
||||
for (const anim of state.activeAnimations) anim.cancel()
|
||||
state.activeAnimations = []
|
||||
|
||||
// ── Exit transition on outgoing flex container ──────────────────────
|
||||
const outgoingFlex = state.videoFlexEl
|
||||
state.videoFlexEl = null
|
||||
state.videoWordEls = []
|
||||
state.videoLineUnits = []
|
||||
|
||||
if (state.overlayEl) {
|
||||
state.overlayEl.innerHTML = ''
|
||||
// Detach outgoing element before innerHTML = '' so we can re-use it
|
||||
if (outgoingFlex) outgoingFlex.remove()
|
||||
state.overlayEl.innerHTML = '' // clear any other stale children
|
||||
|
||||
// Re-attach + animate the outgoing element if a transition is chosen
|
||||
const transDef = outgoingFlex && style.videoLineTransition !== 'none'
|
||||
? VIDEO_TRANSITION_REGISTRY.find(t => t.name === style.videoLineTransition)
|
||||
: undefined
|
||||
if (outgoingFlex && transDef) {
|
||||
outgoingFlex.style.pointerEvents = 'none'
|
||||
state.overlayEl.appendChild(outgoingFlex)
|
||||
const exitAnim = transDef.animate(outgoingFlex)
|
||||
const removeAfter = transDef.duration + 50
|
||||
setTimeout(() => { exitAnim.cancel(); outgoingFlex.remove() }, removeAfter)
|
||||
}
|
||||
|
||||
if (newActiveIdx >= 0 && newActiveIdx < lines.length) {
|
||||
const activeLine = lines[newActiveIdx]
|
||||
const lineColor = activeLine.speaker ? speakerColorFn(activeLine.speaker) : style.textColor
|
||||
const words = activeLine.words && activeLine.words.length > 0 ? activeLine.words : null
|
||||
const gran = style.videoGranularity
|
||||
// Scroll mode uses explicit user granularity. Line mode auto-selects
|
||||
// the finest timed units available: ELRC syllables if present,
|
||||
// otherwise LRC word buckets.
|
||||
const isStaticLineReveal = displayMode === 'line'
|
||||
const gran: 'word' | 'syllable' = isStaticLineReveal
|
||||
? (words ? 'syllable' : 'word')
|
||||
: (style.videoGranularity === 'syllable' ? 'syllable' : 'word')
|
||||
|
||||
const flexDiv = makeFlexDiv()
|
||||
const flexDiv = makeFlexDiv(lineColor)
|
||||
state.overlayEl.appendChild(flexDiv)
|
||||
state.videoFlexEl = flexDiv
|
||||
|
||||
@@ -972,8 +1029,21 @@ function updateScene(
|
||||
const wordEl = document.createElement('span')
|
||||
wordEl.style.cssText = 'display:inline-flex;align-items:baseline'
|
||||
state.videoWordEls.push(wordEl)
|
||||
if (isStaticLineReveal) state.videoFlexEl.appendChild(wordEl)
|
||||
for (const syl of buckets[wi]) {
|
||||
state.videoLineUnits.push({ text: syl.text, time: syl.time, added: false, wordElIdx: wi })
|
||||
let sylEl: HTMLSpanElement | null = null
|
||||
if (isStaticLineReveal) {
|
||||
sylEl = document.createElement('span')
|
||||
sylEl.setAttribute('data-unit', '')
|
||||
sylEl.textContent = syl.text
|
||||
sylEl.style.display = 'inline-block'
|
||||
sylEl.style.visibility = 'hidden'
|
||||
sylEl.style.webkitTextStroke = strokeVal
|
||||
sylEl.style.textShadow = shadowVal
|
||||
;(sylEl.style as any).paintOrder = 'stroke fill'
|
||||
wordEl.appendChild(sylEl)
|
||||
}
|
||||
state.videoLineUnits.push({ text: syl.text, time: syl.time, added: false, wordElIdx: wi, el: sylEl })
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -985,7 +1055,19 @@ function updateScene(
|
||||
syllables: [{ text: t, time: activeLine.time + i * 0.2 }],
|
||||
}))
|
||||
for (const wg of wGroups) {
|
||||
state.videoLineUnits.push({ text: wg.text, time: wg.startTime, added: false, wordElIdx: -1 })
|
||||
let wordSpan: HTMLSpanElement | null = null
|
||||
if (isStaticLineReveal) {
|
||||
wordSpan = document.createElement('span')
|
||||
wordSpan.setAttribute('data-unit', '')
|
||||
wordSpan.textContent = wg.text
|
||||
wordSpan.style.display = 'inline-block'
|
||||
wordSpan.style.visibility = 'hidden'
|
||||
wordSpan.style.webkitTextStroke = strokeVal
|
||||
wordSpan.style.textShadow = shadowVal
|
||||
;(wordSpan.style as any).paintOrder = 'stroke fill'
|
||||
state.videoFlexEl.appendChild(wordSpan)
|
||||
}
|
||||
state.videoLineUnits.push({ text: wg.text, time: wg.startTime, added: false, wordElIdx: -1, el: wordSpan })
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -998,15 +1080,29 @@ function updateScene(
|
||||
if (state.videoFlexEl && state.videoLineUnits.length > 0) {
|
||||
const animDef = VIDEO_ANIM_REGISTRY.find(a => a.name === style.videoAnimStyle)
|
||||
?? VIDEO_ANIM_REGISTRY[0]
|
||||
const isStaticLineReveal = displayMode === 'line'
|
||||
for (const unit of state.videoLineUnits) {
|
||||
if (unit.added || unit.time > time) continue
|
||||
unit.added = true
|
||||
|
||||
if (isStaticLineReveal && unit.el) {
|
||||
unit.el.style.visibility = 'visible'
|
||||
const activeLine = (newActiveIdx >= 0 && newActiveIdx < lines.length) ? lines[newActiveIdx] : null
|
||||
const lineColor = activeLine?.speaker ? speakerColorFn(activeLine.speaker) : style.textColor
|
||||
animateSpan(unit.el, animDef, lineColor)
|
||||
continue
|
||||
}
|
||||
|
||||
const span = document.createElement('span')
|
||||
span.setAttribute('data-unit', '')
|
||||
span.textContent = unit.text
|
||||
span.style.display = 'inline-block'
|
||||
animateSpan(span, animDef)
|
||||
span.style.webkitTextStroke = strokeVal
|
||||
span.style.textShadow = shadowVal
|
||||
;(span.style as any).paintOrder = 'stroke fill'
|
||||
const activeLine = (newActiveIdx >= 0 && newActiveIdx < lines.length) ? lines[newActiveIdx] : null
|
||||
const lineColor = activeLine?.speaker ? speakerColorFn(activeLine.speaker) : style.textColor
|
||||
animateSpan(span, animDef, lineColor)
|
||||
|
||||
if (unit.wordElIdx >= 0) {
|
||||
const wordEl = state.videoWordEls[unit.wordElIdx]
|
||||
@@ -1019,7 +1115,7 @@ function updateScene(
|
||||
}
|
||||
|
||||
} else {
|
||||
// ── Non-scroll modes: one unit at a time (line / word / syllable) ──
|
||||
// ── Word/Syllable modes: one unit at a time ──────────────────────────
|
||||
let activeUnitIdx = -1
|
||||
if (newActiveIdx >= 0) {
|
||||
const al = lines[newActiveIdx]
|
||||
@@ -1042,18 +1138,16 @@ function updateScene(
|
||||
if (state.overlayEl) {
|
||||
state.overlayEl.innerHTML = ''
|
||||
|
||||
const canRender = newActiveIdx >= 0 && newActiveIdx < lines.length &&
|
||||
!((displayMode === 'word' || displayMode === 'syllable') && activeUnitIdx < 0)
|
||||
const canRender = newActiveIdx >= 0 && newActiveIdx < lines.length && activeUnitIdx >= 0
|
||||
|
||||
if (canRender) {
|
||||
const activeLine = lines[newActiveIdx]
|
||||
const lineColor = activeLine.speaker ? speakerColorFn(activeLine.speaker) : style.textColor
|
||||
const words = activeLine.words && activeLine.words.length > 0 ? activeLine.words : null
|
||||
const flexDiv = makeFlexDiv()
|
||||
const flexDiv = makeFlexDiv(lineColor)
|
||||
|
||||
let spanText: string
|
||||
if (displayMode === 'line') {
|
||||
spanText = activeLine.text
|
||||
} else if (displayMode === 'word') {
|
||||
if (displayMode === 'word') {
|
||||
const groups = state.lineWordGroups[newActiveIdx] ?? []
|
||||
spanText = groups[activeUnitIdx]?.text ?? activeLine.text
|
||||
} else {
|
||||
@@ -1063,13 +1157,14 @@ function updateScene(
|
||||
const span = document.createElement('span')
|
||||
span.setAttribute('data-unit', '')
|
||||
span.textContent = spanText
|
||||
span.style.cssText = displayMode === 'line'
|
||||
? 'display:inline-block;max-width:100%;word-break:break-word'
|
||||
: 'display:inline-block'
|
||||
span.style.cssText = 'display:inline-block'
|
||||
span.style.webkitTextStroke = strokeVal
|
||||
span.style.textShadow = shadowVal
|
||||
;(span.style as any).paintOrder = 'stroke fill'
|
||||
const animDef = VIDEO_ANIM_REGISTRY.find(a => a.name === style.videoAnimStyle)
|
||||
?? VIDEO_ANIM_REGISTRY[0]
|
||||
// animateSpan moves span to a temp div to isolate it; move it back after.
|
||||
animateSpan(span, animDef)
|
||||
animateSpan(span, animDef, lineColor)
|
||||
flexDiv.appendChild(span)
|
||||
state.overlayEl.appendChild(flexDiv)
|
||||
}
|
||||
@@ -1307,7 +1402,7 @@ export default function LyricsCanvas({
|
||||
karaokeMode: style.karaokeMode, glowSize: style.glowSize,
|
||||
popScale: style.popScale, popSnap: style.popSnap,
|
||||
videoAnimStyle: style.videoAnimStyle, videoGranularity: style.videoGranularity,
|
||||
videoDisplayMode: style.videoDisplayMode,
|
||||
videoDisplayMode: style.videoDisplayMode, videoLineTransition: style.videoLineTransition,
|
||||
})
|
||||
useEffect(() => {
|
||||
const state = stateRef.current
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useState, useEffect, useLayoutEffect, useRef, useCallback, useMemo } from 'react'
|
||||
import { VIDEO_ANIM_REGISTRY, type VideoAnimStyle, type VideoTimingGranularity } from '../utils/videoAnimations'
|
||||
import { VIDEO_ANIM_REGISTRY, VIDEO_TRANSITION_REGISTRY, type VideoAnimStyle, type VideoTimingGranularity, type VideoLineTransition } from '../utils/videoAnimations'
|
||||
import { Play, Pause, SkipBack, Volume2, VolumeX, Palette, Pencil, X, AlignLeft, AlignCenter, AlignRight, Type, Crosshair, Maximize2, Minimize2, Activity } from 'lucide-react'
|
||||
import type { LyricsStyleOptions } from '../types'
|
||||
import { registerPlayback, unregisterPlayback, publishMeta, clearMeta } from '../utils/audioRegistry'
|
||||
@@ -433,9 +433,10 @@ interface StyleState {
|
||||
popScale: number
|
||||
popSnap: number
|
||||
glowSize: number
|
||||
videoAnimStyle: VideoAnimStyle
|
||||
videoGranularity: VideoTimingGranularity
|
||||
videoDisplayMode: 'scroll' | 'line' | 'word' | 'syllable'
|
||||
videoAnimStyle: VideoAnimStyle
|
||||
videoGranularity: VideoTimingGranularity
|
||||
videoDisplayMode: 'scroll' | 'line' | 'word' | 'syllable'
|
||||
videoLineTransition: VideoLineTransition
|
||||
}
|
||||
|
||||
const DEFAULT_STYLE: StyleState = {
|
||||
@@ -464,9 +465,10 @@ const DEFAULT_STYLE: StyleState = {
|
||||
popScale: 15,
|
||||
popSnap: 150,
|
||||
glowSize: 8,
|
||||
videoAnimStyle: 'fadeUp',
|
||||
videoGranularity: 'word',
|
||||
videoDisplayMode: 'scroll',
|
||||
videoAnimStyle: 'fadeUp',
|
||||
videoGranularity: 'word',
|
||||
videoDisplayMode: 'scroll',
|
||||
videoLineTransition: 'fadeOut',
|
||||
}
|
||||
|
||||
function StylePicker({
|
||||
@@ -709,6 +711,20 @@ function StylePicker({
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
{/* Line exit-transition row */}
|
||||
<div className="flex items-center gap-1.5 flex-wrap">
|
||||
<span className="text-[10px] text-slate-500 w-8 shrink-0">Exit</span>
|
||||
<select
|
||||
value={style.videoLineTransition}
|
||||
onChange={e => onChange({ videoLineTransition: e.target.value as VideoLineTransition })}
|
||||
className="text-[10px] bg-slate-700 border border-slate-600 rounded px-1 py-0.5 text-slate-200"
|
||||
title="Line exit transition"
|
||||
>
|
||||
{VIDEO_TRANSITION_REGISTRY.map(t => (
|
||||
<option key={t.name} value={t.name}>{t.label}</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
@@ -2012,6 +2028,7 @@ export default function LyricsLivePreview({ lrcText, audioUrl, stems, title, sty
|
||||
videoAnimStyle: style.videoAnimStyle,
|
||||
videoGranularity: style.videoGranularity,
|
||||
videoDisplayMode: style.videoDisplayMode,
|
||||
videoLineTransition: style.videoLineTransition,
|
||||
}}
|
||||
speakerColorFn={getSpeakerColor}
|
||||
/>
|
||||
|
||||
@@ -16,9 +16,95 @@ export type VideoAnimStyle =
|
||||
| 'fadeUp' | 'fadeDown' | 'scaleIn' | 'rotateIn'
|
||||
| 'slideLeft' | 'slideRight' | 'popIn' | 'waveUp'
|
||||
| 'typewriter' | 'blur' | 'flipIn' | 'swingIn'
|
||||
| 'zoomIn' | 'curtain' | 'tumble' | 'springIn' | 'riseStrong' | 'fallIn'
|
||||
|
||||
export type VideoTimingGranularity = 'line' | 'word' | 'syllable'
|
||||
|
||||
// ── Line-exit / transition presets ───────────────────────────────────────────
|
||||
|
||||
export type VideoLineTransition =
|
||||
| 'none' | 'fadeOut' | 'slideOutLeft' | 'slideOutUp' | 'scaleOut' | 'blurOut'
|
||||
|
||||
export interface VideoLineTransitionDef {
|
||||
name: VideoLineTransition
|
||||
label: string
|
||||
/** How long the exit animation runs (ms). The outgoing element is removed after this. */
|
||||
duration: number
|
||||
/** Animate the outgoing container element and return the resulting Animation. */
|
||||
animate(container: HTMLElement): Animation
|
||||
}
|
||||
|
||||
const EXIT_DUR = 350
|
||||
const EXIT_EASING = 'cubic-bezier(0.55, 0, 1, 0.45)'
|
||||
|
||||
export const VIDEO_TRANSITION_REGISTRY: VideoLineTransitionDef[] = [
|
||||
{
|
||||
name: 'none',
|
||||
label: 'None',
|
||||
duration: 0,
|
||||
animate: (el) => el.animate([], { duration: 0 }),
|
||||
},
|
||||
{
|
||||
name: 'fadeOut',
|
||||
label: 'Fade Out',
|
||||
duration: EXIT_DUR,
|
||||
animate(el) {
|
||||
return el.animate(
|
||||
[{ opacity: 1 }, { opacity: 0 }],
|
||||
{ duration: EXIT_DUR, easing: 'ease-in', fill: 'forwards' },
|
||||
)
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'slideOutLeft',
|
||||
label: 'Slide Left',
|
||||
duration: EXIT_DUR,
|
||||
animate(el) {
|
||||
return el.animate(
|
||||
[{ opacity: 1, transform: 'translateX(0)' },
|
||||
{ opacity: 0, transform: 'translateX(-80px)' }],
|
||||
{ duration: EXIT_DUR, easing: EXIT_EASING, fill: 'forwards' },
|
||||
)
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'slideOutUp',
|
||||
label: 'Slide Up',
|
||||
duration: EXIT_DUR,
|
||||
animate(el) {
|
||||
return el.animate(
|
||||
[{ opacity: 1, transform: 'translateY(0)' },
|
||||
{ opacity: 0, transform: 'translateY(-60px)' }],
|
||||
{ duration: EXIT_DUR, easing: EXIT_EASING, fill: 'forwards' },
|
||||
)
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'scaleOut',
|
||||
label: 'Scale Out',
|
||||
duration: EXIT_DUR,
|
||||
animate(el) {
|
||||
return el.animate(
|
||||
[{ opacity: 1, transform: 'scale(1)' },
|
||||
{ opacity: 0, transform: 'scale(0.65)' }],
|
||||
{ duration: EXIT_DUR, easing: EXIT_EASING, fill: 'forwards' },
|
||||
)
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'blurOut',
|
||||
label: 'Blur Out',
|
||||
duration: EXIT_DUR,
|
||||
animate(el) {
|
||||
return el.animate(
|
||||
[{ opacity: 1, filter: 'blur(0)' },
|
||||
{ opacity: 0, filter: 'blur(14px)' }],
|
||||
{ duration: EXIT_DUR, easing: 'ease-in', fill: 'forwards' },
|
||||
)
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
export interface VideoAnimDef {
|
||||
name: VideoAnimStyle
|
||||
label: string
|
||||
@@ -196,4 +282,90 @@ export const VIDEO_ANIM_REGISTRY: VideoAnimDef[] = [
|
||||
})
|
||||
},
|
||||
},
|
||||
|
||||
// ── Moving Letters additions ──────────────────────────────────────────────
|
||||
|
||||
{
|
||||
// #2 Sunny mornings — letters zoom in from scale 4
|
||||
name: 'zoomIn',
|
||||
label: 'Zoom In',
|
||||
animate(container, _, { active }) {
|
||||
return spans(container).map((el, i) =>
|
||||
el.animate(
|
||||
[{ opacity: 0, transform: 'scale(4)', color: active },
|
||||
{ opacity: 1, transform: 'scale(1)', color: active }],
|
||||
{ duration: 950, delay: unitDelay(el, i), easing: 'cubic-bezier(0.19, 1, 0.22, 1)', fill: 'both' },
|
||||
))
|
||||
},
|
||||
},
|
||||
{
|
||||
// #6 Beautiful Questions — tight upward slide (curtain reveal feel)
|
||||
name: 'curtain',
|
||||
label: 'Curtain',
|
||||
animate(container, _, { active }) {
|
||||
return spans(container).map((el, i) =>
|
||||
el.animate(
|
||||
[{ opacity: 0, transform: 'translateY(0.8em)', color: active },
|
||||
{ opacity: 1, transform: 'translateY(0)', color: active }],
|
||||
{ duration: 600, delay: unitDelay(el, i), easing: EASING, fill: 'both' },
|
||||
))
|
||||
},
|
||||
},
|
||||
{
|
||||
// #7 Reality is broken — letters tumble in (translateY + rotateZ 180→0)
|
||||
name: 'tumble',
|
||||
label: 'Tumble',
|
||||
animate(container, _, { active }) {
|
||||
return spans(container).map((el, i) =>
|
||||
el.animate(
|
||||
[{ opacity: 0, transform: 'translateY(0.8em) translateX(0.35em) rotateZ(180deg)', color: active },
|
||||
{ opacity: 1, transform: 'translateY(0) translateX(0) rotateZ(0deg)', color: active }],
|
||||
{ duration: 750, delay: unitDelay(el, i), easing: 'cubic-bezier(0.19, 1, 0.22, 1)', fill: 'both' },
|
||||
))
|
||||
},
|
||||
},
|
||||
{
|
||||
// #9 Coffee mornings — elastic spring scale using multi-keyframe overshoot
|
||||
name: 'springIn',
|
||||
label: 'Spring In',
|
||||
animate(container, _, { active }) {
|
||||
return spans(container).map((el, i) =>
|
||||
el.animate(
|
||||
[
|
||||
{ opacity: 0, transform: 'scale(0)', color: active, offset: 0 },
|
||||
{ opacity: 1, transform: 'scale(1.25)', color: active, offset: 0.55 },
|
||||
{ opacity: 1, transform: 'scale(0.92)', color: active, offset: 0.72 },
|
||||
{ opacity: 1, transform: 'scale(1.05)', color: active, offset: 0.87 },
|
||||
{ opacity: 1, transform: 'scale(1)', color: active, offset: 1 },
|
||||
],
|
||||
{ duration: 900, delay: unitDelay(el, i), easing: 'linear', fill: 'both' },
|
||||
))
|
||||
},
|
||||
},
|
||||
{
|
||||
// #13 Rising Strong — dramatic rise from 80 px below, easeOutExpo
|
||||
name: 'riseStrong',
|
||||
label: 'Rise Strong',
|
||||
animate(container, _, { active }) {
|
||||
return spans(container).map((el, i) =>
|
||||
el.animate(
|
||||
[{ opacity: 0, transform: 'translateY(80px)', color: active },
|
||||
{ opacity: 1, transform: 'translateY(0)', color: active }],
|
||||
{ duration: 1000, delay: unitDelay(el, i), easing: 'cubic-bezier(0.19, 1, 0.22, 1)', fill: 'both' },
|
||||
))
|
||||
},
|
||||
},
|
||||
{
|
||||
// #16 Made With Love — letters rain down from above
|
||||
name: 'fallIn',
|
||||
label: 'Fall In',
|
||||
animate(container, _, { active }) {
|
||||
return spans(container).map((el, i) =>
|
||||
el.animate(
|
||||
[{ opacity: 0, transform: 'translateY(-80px)', color: active },
|
||||
{ opacity: 1, transform: 'translateY(0)', color: active }],
|
||||
{ duration: 1000, delay: unitDelay(el, i), easing: 'cubic-bezier(0.19, 1, 0.22, 1)', fill: 'both' },
|
||||
))
|
||||
},
|
||||
},
|
||||
]
|
||||
Reference in new issue
Block a user