Repository navigation
Conversation
A toolbar button next to Fit and the Z key zoom and scroll the timeline so the selected clips span its width, through zoomTimelineToRange. The button is disabled, with a tooltip saying why, while no clip is selected. Fixes heygen-com#5581
4 tasks done
Collaborator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a "Zoom to selected clips" button to the timeline toolbar, next to Fit, and the Z key for the same action. The timeline zooms and scrolls so the selected clips span its visible width. With no clip selected the button is disabled and its tooltip says "Select clips to zoom to them".
Why
Fit shows the whole composition, but tightening a cut in a long one means zooming in by hand and then scrolling to find the clips again.
Related work
Fixes #5581
How
selectedClipsRangeintimelineSelectionZoom.tsis the one function that holds the math. It takes the timeline elements and the selected ids and returns the span from the first selected clip's start to the last one's end, ornullwhen nothing selected resolves to a clip. It matches ids the way the Delete key does (key ?? id, plus the selection anchor).zoomToSelectedClipshands that span to the existingzoomTimelineToRange, which already eases the zoom, clamps it to the zoom limits and leaves the 24px range margin on each side. Nothing new was needed for the zoom or the scroll themselves.ZoomToSelectionButton.tsx, soTimelineToolbar.tsxstays under the 600-line cap.STUDIO_PLAIN_KEYSand to the shortcuts panel under Editing. Only ⌘Z and ⌘⇧Z were bound before, and the plain-key dispatcher already skips text fields.file#id, which is not in the timeline element list, so selecting only those leaves the button disabled. The S split key has the same limit today.Before
After
Test plan
Unit tests added/updated
Manual testing performed
Documentation updated (if applicable)
Comments follow CONTRIBUTING.md "Comments": they say why, not what, and a bug fix says what the code must do and how to reproduce the bug
timelineSelectionZoom.test.tscovers the range for a single clip, several clips with gaps, a long clip that ends after a later one, clips at the very start and end, keyed ids, and an empty or unresolvable selection. It also drives the real zoom on a mounted viewport, checking that the span fills the width between the margins and that a first or last clip stays on screen.TimelineToolbar.test.tsxcovers the button's disabled and enabled states, a click, and the Z key with and without a selection.In Chrome on the
studio-openfixture, I selected Scene4 and Scene5 and pressed Z. They went from 254px at Fit to spanning x=107 to 1892 of the 1920px timeline. With the first clip selected it landed at x=84 to 1868, and with the last clip at x=107 to 1892.bun run --cwd packages/studio test,bun run lint,bun run format:check,bun run --filter '*' typecheck, the comment citation and ratchet checks,bunx fallow audit --base origin/main --fail-on-issuesand the test reachability check all pass locally.