- Remove splitAreaEl dependency from handleResizeMove; use fixed 40-500 clamp - Add computeLanes() + LaneLayout for dynamic lane height computation - Update clipRenderer to accept LaneLayout instead of hardcoded constants - Tighten CONTROLS_HEIGHT (30→22) and CLIP_HEIGHT (30→20) to reduce gaps - Tighten label baseline offset (14→10) for better waveform-to-tick alignment Co-authored-by: Cursor <cursoragent@cursor.com>
2.7 KiB
2.7 KiB
Fix Resize + Waveform Alignment
Date: 2026-09-22 17:42 Task: Implement the "Fix Resize + Waveform Alignment" plan to fix horizontal resize regression and waveform/lane alignment issues.
Changes Made
1. Resize Regression Fix — src/App.svelte
- Root cause: After the CSS-grid refactor,
handleResizeMoveusedsplitAreaEl.clientHeightas the upper bound. Since.lower-sectiononly contained the resize handle (5px) + timeline pane,totalHeight ≈ timelineHeight + 5, so the clampMath.min(totalHeight - 20, ...)immediately locked the height. - Fix:
- Removed
splitAreaElstate variable. - Removed
bind:this={splitAreaEl}from the.lower-sectiondiv. - Simplified
handleResizeMoveto use a fixed max of 500 (matching the existing keyboard resize handler):Math.max(40, Math.min(500, resizeStartHeight + delta)).
- Removed
2. Dynamic Lane Layout — src/lib/timeline/renderer.ts
- Removed fixed lane height constants (
THUMB_LANE_HEIGHT,WAVEFORM_LANE_HEIGHT,CONTROLS_LANE_HEIGHT). - Added
LaneLayoutinterface andcomputeLanes(totalHeight)function that dynamically computes lane positions proportionally based on total canvas height.- Controls lane: fixed 30px at bottom.
- Clip lane: fixed 30px above controls.
- Remaining space split 55/45 between thumbnails and waveform (with minimums of 20px and 15px).
- Updated
drawTimelineto callcomputeLanes(height)and pass layout to all sub-draw functions. - Updated
drawTimeTicksto acceptLaneLayoutand uselanes.controlsYinstead ofstate.height - CONTROLS_LANE_HEIGHT.
3. Clip Renderer Update — src/lib/timeline/clipRenderer.ts
- Removed hardcoded
CLIP_LANE_YandCLIP_LANE_HEIGHTconstants. - Updated
drawClipsandhitTestClipsignatures to acceptLaneLayoutparameter. - All clip positioning now uses
lanes.clipYandlanes.clipHeight.
4. Timeline Component Update — src/lib/components/Timeline.svelte
- Imported
computeLanesfrom renderer. - Updated
hitTestClipcall to passcomputeLanes(timelineState.height).
Verification
npm run check(svelte-check): 0 errors, 0 warnings.
Files Modified
src/App.sveltesrc/lib/timeline/renderer.tssrc/lib/timeline/clipRenderer.tssrc/lib/components/Timeline.svelte
Lessons Learned
- When using CSS grid layouts, elements that previously represented the "total space" may now only contain their own children. Relying on
clientHeightof such elements for resize calculations breaks — use fixed bounds instead. - Dynamic lane computation is preferable to fixed pixel constants because it adapts to any canvas height, preventing gaps or overlaps when the user resizes the timeline.