-
Notifications
You must be signed in to change notification settings - Fork 810
fix: smooth scrubber end seeking #386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
bd43d21
fix: smooth scrubber end seeking
miguel-heygen f017b64
fix: stop timeline auto-scroll in fit mode
miguel-heygen a0b22f5
feat: use percentage-based timeline zoom
miguel-heygen 535cf6f
fix: sync timeline playhead on zoom changes
miguel-heygen 6ba3f40
fix: reset timeline scroll when returning to fit
miguel-heygen 8763cb8
fix: keep timeline controls pinned
miguel-heygen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
20 changes: 20 additions & 0 deletions
20
packages/studio/src/player/components/PlayerControls.test.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import { describe, expect, it } from "vitest"; | ||
| import { resolveSeekPercent } from "./PlayerControls"; | ||
|
|
||
| describe("resolveSeekPercent", () => { | ||
| it("returns 0 when the track width is invalid", () => { | ||
| expect(resolveSeekPercent(100, 0, 0)).toBe(0); | ||
| }); | ||
|
|
||
| it("snaps to the start within the edge threshold", () => { | ||
| expect(resolveSeekPercent(105, 100, 200)).toBe(0); | ||
| }); | ||
|
|
||
| it("snaps to the end within the edge threshold", () => { | ||
| expect(resolveSeekPercent(298, 100, 200)).toBe(1); | ||
| }); | ||
|
|
||
| it("preserves the true percent away from the edges", () => { | ||
| expect(resolveSeekPercent(150, 100, 200)).toBe(0.25); | ||
| }); | ||
| }); |
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
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
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
62 changes: 62 additions & 0 deletions
62
packages/studio/src/player/components/timelineZoom.test.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| import { describe, expect, it } from "vitest"; | ||
| import { | ||
| clampTimelineZoomPercent, | ||
| getNextTimelineZoomPercent, | ||
| getTimelinePixelsPerSecond, | ||
| getTimelineZoomPercent, | ||
| MAX_TIMELINE_ZOOM_PERCENT, | ||
| MIN_TIMELINE_ZOOM_PERCENT, | ||
| } from "./timelineZoom"; | ||
|
|
||
| describe("clampTimelineZoomPercent", () => { | ||
| it("defaults invalid values to 100", () => { | ||
| expect(clampTimelineZoomPercent(Number.NaN)).toBe(100); | ||
| }); | ||
|
|
||
| it("clamps to the supported percent bounds", () => { | ||
| expect(clampTimelineZoomPercent(1)).toBe(MIN_TIMELINE_ZOOM_PERCENT); | ||
| expect(clampTimelineZoomPercent(5000)).toBe(MAX_TIMELINE_ZOOM_PERCENT); | ||
| }); | ||
| }); | ||
|
|
||
| describe("getTimelineZoomPercent", () => { | ||
| it("treats fit mode as 100 percent", () => { | ||
| expect(getTimelineZoomPercent("fit", 375)).toBe(100); | ||
| }); | ||
|
|
||
| it("returns the clamped manual zoom percent", () => { | ||
| expect(getTimelineZoomPercent("manual", 125.2)).toBe(125); | ||
| }); | ||
| }); | ||
|
|
||
| describe("getTimelinePixelsPerSecond", () => { | ||
| it("uses fit pixels per second in fit mode", () => { | ||
| expect(getTimelinePixelsPerSecond(144, "fit", 250)).toBe(144); | ||
| }); | ||
|
|
||
| it("scales from fit pixels per second in manual mode", () => { | ||
| expect(getTimelinePixelsPerSecond(144, "manual", 125)).toBe(180); | ||
| }); | ||
| }); | ||
|
|
||
| describe("getNextTimelineZoomPercent", () => { | ||
| it("zooms out from fit relative to 100 percent", () => { | ||
| expect(getNextTimelineZoomPercent("out", "fit", 375)).toBe(80); | ||
| }); | ||
|
|
||
| it("zooms in from fit relative to 100 percent", () => { | ||
| expect(getNextTimelineZoomPercent("in", "fit", 375)).toBe(125); | ||
| }); | ||
|
|
||
| it("clamps the lower bound", () => { | ||
| expect(getNextTimelineZoomPercent("out", "manual", MIN_TIMELINE_ZOOM_PERCENT)).toBe( | ||
| MIN_TIMELINE_ZOOM_PERCENT, | ||
| ); | ||
| }); | ||
|
|
||
| it("clamps the upper bound", () => { | ||
| expect(getNextTimelineZoomPercent("in", "manual", MAX_TIMELINE_ZOOM_PERCENT)).toBe( | ||
| MAX_TIMELINE_ZOOM_PERCENT, | ||
| ); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.