mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-17 23:47:33 +00:00
* fix(studio): a hand drag moves only with its own pointer pressed Chromium re-sends the last known pointer point with no button held after a layout change. The overlay's move handler took those as drag travel, so the element flipped between the pointer and that stale point, and the release committed whichever came last. * test(studio): the edit accuracy grid drops a drag after a buttonless move at the press point Nine pathstray cases: a 180,90 drag whose last move before the release is a buttonless pointermove back at the press point, as Chromium resends after a layout change. Main saves the element where it started; this head saves it where the pointer let go. The frame sampler ignores that untrusted move as pointer position. * fix(studio): keep the drag rule's comment to one line * fix(studio): crop handles and the marquee band also ignore a buttonless move mid-gesture * test(studio): bank the nine stray-move cases in the edit accuracy baseline * test(studio): one crop drag helper, the band's candidate refresh in its own step, and formatting * style(studio): wrap the pointer gesture comment under 120 characters
76 lines
3.0 KiB
JavaScript
76 lines
3.0 KiB
JavaScript
// Drag paths (one long move) and sequences (several edits, no settle between), gsap none.
|
|
// Ids keep the grid's scheme with a letters-only gesture token, so `^[a-z]+-none-` selects them.
|
|
|
|
const MOVE = { do: "drag", gesture: "move", by: [90, 60] };
|
|
const BACK = { do: "drag", gesture: "move", by: [-70, 50] };
|
|
const UP = { do: "drag", gesture: "move", by: [60, -80] };
|
|
|
|
const PATHS = ["zigzag", "circle", "flick", "pause", "edge", "stray"];
|
|
|
|
/** Each sequence's steps; a drag names its element (A is #target, B is #other) and its screen-px path. */
|
|
const SEQUENCES = {
|
|
repeat: [MOVE, BACK, UP],
|
|
undo: [MOVE, { do: "undo" }, BACK],
|
|
nudge: [MOVE, { do: "nudge", count: 3 }, BACK],
|
|
ab: [MOVE, { ...BACK, element: "B" }, { ...UP, element: "A" }],
|
|
resize: [{ do: "drag", gesture: "resize" }, MOVE],
|
|
seek: [{ do: "seek", time: 2 }, MOVE],
|
|
// Pressed again in the frame after pointer-up, while that drag's save is still in flight.
|
|
inflight: [MOVE, { ...BACK, inFlight: true }],
|
|
// Undone at once, before the edit's save lands: the undo must win.
|
|
resizeundo: [{ do: "drag", gesture: "resize" }, { do: "undo" }],
|
|
nudgeundo: [{ do: "nudge", count: 1 }, { do: "undo" }],
|
|
rotatenudge: [
|
|
{ do: "drag", gesture: "rotate" },
|
|
{ do: "nudge", count: 3 },
|
|
],
|
|
};
|
|
|
|
/** Text in place: a double press opens it, Enter commits; `select` first double-clicks a word to replace. */
|
|
const TEXT = {
|
|
edit: [{ do: "text", word: "Teleport" }],
|
|
select: [{ do: "text", word: "Teleport", select: "accuracy" }],
|
|
};
|
|
|
|
const row = (gesture, c, steps) => ({
|
|
id: [gesture, "none", c.placement, `r${c.rotation}`, c.nesting, `z${c.zoom}`].join("-"),
|
|
gesture,
|
|
gsap: "none",
|
|
...c,
|
|
steps,
|
|
other: Boolean(steps?.some((s) => s.element === "B")),
|
|
});
|
|
|
|
const base = { rotation: 0, zoom: 100 };
|
|
const everyPlacement = ["px", "pct", "center"].flatMap((placement) =>
|
|
["root", "nested"].map((nesting) => ({ ...base, placement, nesting })),
|
|
);
|
|
const pxRoot = (extra) => ({ ...base, placement: "px", nesting: "root", ...extra });
|
|
|
|
export function dragCases() {
|
|
const route = (path) => [{ do: "drag", gesture: "move", route: path }];
|
|
const paths = PATHS.flatMap((p) =>
|
|
[...everyPlacement, pxRoot({ rotation: 30 }), pxRoot({ zoom: 50 }), pxRoot({ zoom: 200 })].map(
|
|
(c) => row(`path${p}`, c, route(p)),
|
|
),
|
|
);
|
|
const sequences = Object.entries(SEQUENCES).flatMap(([name, steps]) =>
|
|
everyPlacement.map((c) => row(`seq${name}`, c, steps)),
|
|
);
|
|
const texts = Object.entries(TEXT).flatMap(([name, steps]) =>
|
|
["root", "nested"].map((nesting) => ({
|
|
...row(`text${name}`, { ...base, placement: "px", nesting }, steps),
|
|
text: true,
|
|
})),
|
|
);
|
|
// Rotate on the common centring idiom, a transform rather than the translate property.
|
|
const centred = [0, 30].flatMap((rotation) =>
|
|
["root", "nested"].map((nesting) => ({
|
|
...row("rotate", { ...base, rotation, placement: "transform", nesting }, undefined),
|
|
steps: undefined,
|
|
other: false,
|
|
})),
|
|
);
|
|
return [...paths, ...sequences, ...texts, ...centred];
|
|
}
|