From b8471416d845519155d8a785a022e621e94ce76c Mon Sep 17 00:00:00 2001 From: = <=> Date: Mon, 13 Jul 2026 11:50:39 +0300 Subject: [PATCH] feat: use multiple clips for 'zoom to selection' ('z') --- app.js | 13 ++++++++----- index.html | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app.js b/app.js index d0962a7d2..6d6e1b494 100644 --- a/app.js +++ b/app.js @@ -1219,17 +1219,20 @@ function zoomToFit() { setZoom(w / span); els.timelineScroll.scrollLeft = 0; } -/* Zoom so the primary selected clip fills 90% of the timeline width and is centered. */ +/* Zoom so the selection fills 90% of the timeline width and is centered. + One clip → that clip; multiple → the time range covering all of them. */ function zoomToSelection() { - const c = getClip(state.selId) || selectedClips()[0]; - if (!c) { toast("Select a clip to zoom to"); return; } + const clips = selectedClips(); + if (!clips.length) { toast("Select a clip to zoom to"); return; } + const t0 = Math.min(...clips.map((c) => c.start)); + const t1 = Math.max(...clips.map((c) => c.start + c.duration)); + const dur = Math.max(t1 - t0, MIN_DUR); const w = els.timelineScroll.clientWidth || 800; - const dur = Math.max(c.duration, MIN_DUR); const pps = clamp((0.9 * w) / dur, ZOOM_MIN, ZOOM_MAX); state.pps = pps; els.zoomSlider.value = pps; rebuildClips(); - const center = c.start + c.duration / 2; + const center = (t0 + t1) / 2; const maxScroll = Math.max(0, contentWidth() - w); els.timelineScroll.scrollLeft = clamp(center * pps - w / 2, 0, maxScroll); } diff --git a/index.html b/index.html index 56b3bb5f4..49e971c3b 100644 --- a/index.html +++ b/index.html @@ -163,7 +163,7 @@

Keyboard shortcuts

MAdd / remove marker at playhead (tap on the beat while playing) NToggle snapping + / -Zoom timeline - ZZoom to selected clip + ZZoom to selected clip(s) ⇧+ZZoom timeline to fit Ctrl+Z / Ctrl+⇧+ZUndo / redo Ctrl+wheelZoom timeline at cursor