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
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import type { UseDomEditOverlayGesturesOptions } from "./domEditOverlayGestures"
import { gestureStartReadAhead, keepGestureStartReadAhead } from "./gestureStartReadAhead";
import { createPreviewGestureStarts } from "./previewGestureStarts";
import { standInFor } from "./previewSelection";
import { sealedMotionPathHome } from "./useMotionPathData";
import { useDomEditOverlayRects } from "./useDomEditOverlayRects";

const frames = vi.hoisted(() => new Set<() => void>());
Expand Down Expand Up @@ -131,6 +132,19 @@ const press = () =>
const asked = (kind: string) =>
vi.mocked(previewRequest).mock.calls.filter(([, k]) => k === kind).length;

// fails without the fix: a drawn motion path asks where it starts every frame, and each ask threw away the read
// made before the press, so the press waited on the frame and its first move showed late.
it("starts a press at once while a drawn motion path keeps asking the frame where it starts", async () => {
const { iframe, selection, opts } = await selectBoxOnSealedFrame();
expect(await sealedMotionPathHome(iframe, "#box")).not.toBeNull();

const starts = createPreviewGestureStarts(opts, vi.fn(), vi.fn());
expect(starts.startGesture("drag", press(), { selection })).toBe(true);

expect(opts.gestureRef.current?.selection.handle).toBe(selection.handle);
expect(opts.waitingPressRef.current).toBeNull();
});

// fails without the fix: the press waited on query, describe and gesture-start answers before its gesture started.
it("starts a press on a sealed preview at once from the read made before it, asking the frame nothing", async () => {
const { selection, opts } = await selectBoxOnSealedFrame();
Expand Down
3 changes: 3 additions & 0 deletions packages/studio/src/player/lib/frameFacts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ it("hears a draft or any other write to the frame, and no read of it", () => {
const changes = heard();
frameRequestSent("query");
frameRequestSent("gesture-start");
frameRequestSent("motion-path-home");
frameRequestSent("stage-measure");
frameRequestSent("assets-unloaded");
frameRequestSent("draft");
frameRequestSent("edit-element");
frameRequestSent("soft-reload");
Expand Down
3 changes: 3 additions & 0 deletions packages/studio/src/player/lib/frameFacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ const FRAME_READS: ReadonlySet<EditingRequestKind> = new Set<EditingRequestKind>
"gsap-snapshot",
"max-z-index",
"stacking-family",
"motion-path-home",
"stage-measure",
"assets-unloaded",
]);

export function frameRequestSent(kind: EditingRequestKind): void {
Expand Down
Loading