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
26 changes: 23 additions & 3 deletions src/__tests__/runtime-interactions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -609,16 +609,36 @@ test('runtime gesture swipe presets use stable viewport lanes', async () => {
session: 'default',
});

assert.deepEqual(pageSwipe.from, { x: 90, y: 65 });
assert.deepEqual(pageSwipe.to, { x: 10, y: 65 });
assert.deepEqual(pageSwipe.from, { x: 85, y: 65 });
assert.deepEqual(pageSwipe.to, { x: 15, y: 65 });
assert.deepEqual(edgeSwipe.from, { x: 8, y: 50 });
assert.deepEqual(edgeSwipe.to, { x: 85, y: 50 });
assert.deepEqual(calls, [
{ from: { x: 90, y: 65 }, to: { x: 10, y: 65 }, durationMs: 300 },
{ from: { x: 85, y: 65 }, to: { x: 15, y: 65 }, durationMs: 300 },
{ from: { x: 8, y: 50 }, to: { x: 85, y: 50 }, durationMs: 350 },
]);
});

test('runtime iOS in-page swipe presets avoid edge-navigation lanes', async () => {
const calls: unknown[] = [];
const device = createInteractionDevice(snapshotWithOffscreenContent(), {
platform: 'ios',
swipe: async (_context, from, to, options) => {
calls.push({ from, to, durationMs: options?.durationMs });
},
});

const pageSwipe = await device.interactions.swipe({
preset: 'right',
durationMs: 300,
session: 'default',
});

assert.deepEqual(pageSwipe.from, { x: 15, y: 65 });
assert.deepEqual(pageSwipe.to, { x: 85, y: 65 });
assert.deepEqual(calls, [{ from: { x: 15, y: 65 }, to: { x: 85, y: 65 }, durationMs: 300 }]);
});

test('runtime viewport gestures reject inspect-only macOS surfaces', async () => {
for (const surface of ['desktop', 'menubar'] as const) {
const device = createInteractionDevice(selectorSnapshot(), {
Expand Down
6 changes: 3 additions & 3 deletions src/core/__tests__/dispatch-interactions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ test('handleSwipePresetCommand resolves Android in-page swipe to content lane',
undefined,
);

assert.deepEqual(calls, [[360, 520, 40, 520, 300]]);
assert.deepEqual(calls, [[340, 520, 60, 520, 300]]);
assert.deepEqual(result, {
x1: 360,
x1: 340,
y1: 520,
x2: 40,
x2: 60,
y2: 520,
preset: 'left',
durationMs: 300,
Expand Down
8 changes: 5 additions & 3 deletions src/core/scroll-gesture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,14 @@ export function buildSwipePresetGesturePlan(
options: { platform?: string; marginPx?: number } = {},
): SwipePresetGesturePlan {
const marginPx = options.marginPx ?? 8;
const horizontalLanePercent = options.platform === 'android' ? 65 : 50;
const horizontalLanePercent = 65;
const inPageStartPercent = 85;
const inPageEndPercent = 15;
const [startPercent, endPercent, yPercent] =
preset === 'left'
? [90, 10, horizontalLanePercent]
? [inPageStartPercent, inPageEndPercent, horizontalLanePercent]
: preset === 'right'
? [10, 90, horizontalLanePercent]
? [inPageEndPercent, inPageStartPercent, horizontalLanePercent]
: preset === 'left-edge'
? [99, 15, 50]
: [1, 85, 50];
Expand Down
Loading