mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-11 06:30:03 +00:00
feat(studio): support trackpad timeline pinch zoom
This commit is contained in:
@@ -5,6 +5,7 @@ import {
|
||||
getTimelineCanvasHeight,
|
||||
resolveTimelineAssetDrop,
|
||||
getTimelinePlayheadLeft,
|
||||
getTimelineScrollLeftForZoomAnchor,
|
||||
getTimelineScrollLeftForZoomTransition,
|
||||
shouldHandleTimelineDeleteKey,
|
||||
shouldAutoScrollTimeline,
|
||||
@@ -145,6 +146,47 @@ describe("getTimelineScrollLeftForZoomTransition", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("getTimelineScrollLeftForZoomAnchor", () => {
|
||||
it("preserves the time under the pointer when zooming in", () => {
|
||||
expect(
|
||||
getTimelineScrollLeftForZoomAnchor({
|
||||
pointerX: 300,
|
||||
currentScrollLeft: 200,
|
||||
gutter: 32,
|
||||
currentPixelsPerSecond: 10,
|
||||
nextPixelsPerSecond: 20,
|
||||
duration: 120,
|
||||
}),
|
||||
).toBe(668);
|
||||
});
|
||||
|
||||
it("clamps negative scroll targets", () => {
|
||||
expect(
|
||||
getTimelineScrollLeftForZoomAnchor({
|
||||
pointerX: 300,
|
||||
currentScrollLeft: 0,
|
||||
gutter: 32,
|
||||
currentPixelsPerSecond: 20,
|
||||
nextPixelsPerSecond: 5,
|
||||
duration: 120,
|
||||
}),
|
||||
).toBe(0);
|
||||
});
|
||||
|
||||
it("preserves current scroll when inputs are invalid", () => {
|
||||
expect(
|
||||
getTimelineScrollLeftForZoomAnchor({
|
||||
pointerX: 300,
|
||||
currentScrollLeft: 120,
|
||||
gutter: 32,
|
||||
currentPixelsPerSecond: 0,
|
||||
nextPixelsPerSecond: 20,
|
||||
duration: 120,
|
||||
}),
|
||||
).toBe(120);
|
||||
});
|
||||
});
|
||||
|
||||
describe("getTimelinePlayheadLeft", () => {
|
||||
it("converts time to a pixel offset from the gutter", () => {
|
||||
expect(getTimelinePlayheadLeft(4, 20)).toBe(112);
|
||||
|
||||
Reference in New Issue
Block a user