Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ <h2>Keyboard shortcuts</h2>
<tr><td><kbd>M</kbd></td><td>Add / remove marker at playhead (tap on the beat while playing)</td></tr>
<tr><td><kbd>N</kbd></td><td>Toggle snapping</td></tr>
<tr><td><kbd>+</kbd> / <kbd>-</kbd></td><td>Zoom timeline</td></tr>
<tr><td><kbd>Z</kbd></td><td>Zoom to selected clip</td></tr>
<tr><td><kbd>Z</kbd></td><td>Zoom to selected clip(s)</td></tr>
<tr><td><kbd>⇧</kbd>+<kbd>Z</kbd></td><td>Zoom timeline to fit</td></tr>
<tr><td><kbd>Ctrl</kbd>+<kbd>Z</kbd> / <kbd>Ctrl</kbd>+<kbd>⇧</kbd>+<kbd>Z</kbd></td><td>Undo / redo</td></tr>
<tr><td><kbd>Ctrl</kbd>+wheel</td><td>Zoom timeline at cursor</td></tr>
Expand Down
Loading