import type { RangeWindow } from "./RangeTrack"; // Where a time sits along a `RangeTrack` over a window: the track draws its regions, playhead and // handles by these, and a control laid beside the track (a cut's remove button under it) lines up // with the handle drawn at the same time. export const trackFrac = (t: number, win: RangeWindow) => (t - win.from) / Math.max(win.to - win.from, 1e-6); /** A fraction of the track as a CSS length, held to the track. */ export const trackPct = (f: number) => `${(Math.max(0, Math.min(1, f)) * 100).toFixed(3)}%`; /** A time's place along the track, as its CSS `left`. */ export const trackLeft = (t: number, win: RangeWindow) => trackPct(trackFrac(t, win));