Skip to content

Commit 6370caa

Browse files
committed
fix: avoid iOS edge lane for in-page swipes
1 parent ece193e commit 6370caa

3 files changed

Lines changed: 31 additions & 9 deletions

File tree

src/__tests__/runtime-interactions.test.ts

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -609,16 +609,36 @@ test('runtime gesture swipe presets use stable viewport lanes', async () => {
609609
session: 'default',
610610
});
611611

612-
assert.deepEqual(pageSwipe.from, { x: 90, y: 65 });
613-
assert.deepEqual(pageSwipe.to, { x: 10, y: 65 });
612+
assert.deepEqual(pageSwipe.from, { x: 85, y: 65 });
613+
assert.deepEqual(pageSwipe.to, { x: 15, y: 65 });
614614
assert.deepEqual(edgeSwipe.from, { x: 8, y: 50 });
615615
assert.deepEqual(edgeSwipe.to, { x: 85, y: 50 });
616616
assert.deepEqual(calls, [
617-
{ from: { x: 90, y: 65 }, to: { x: 10, y: 65 }, durationMs: 300 },
617+
{ from: { x: 85, y: 65 }, to: { x: 15, y: 65 }, durationMs: 300 },
618618
{ from: { x: 8, y: 50 }, to: { x: 85, y: 50 }, durationMs: 350 },
619619
]);
620620
});
621621

622+
test('runtime iOS in-page swipe presets avoid edge-navigation lanes', async () => {
623+
const calls: unknown[] = [];
624+
const device = createInteractionDevice(snapshotWithOffscreenContent(), {
625+
platform: 'ios',
626+
swipe: async (_context, from, to, options) => {
627+
calls.push({ from, to, durationMs: options?.durationMs });
628+
},
629+
});
630+
631+
const pageSwipe = await device.interactions.swipe({
632+
preset: 'right',
633+
durationMs: 300,
634+
session: 'default',
635+
});
636+
637+
assert.deepEqual(pageSwipe.from, { x: 15, y: 65 });
638+
assert.deepEqual(pageSwipe.to, { x: 85, y: 65 });
639+
assert.deepEqual(calls, [{ from: { x: 15, y: 65 }, to: { x: 85, y: 65 }, durationMs: 300 }]);
640+
});
641+
622642
test('runtime viewport gestures reject inspect-only macOS surfaces', async () => {
623643
for (const surface of ['desktop', 'menubar'] as const) {
624644
const device = createInteractionDevice(selectorSnapshot(), {

src/core/__tests__/dispatch-interactions.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,11 @@ test('handleSwipePresetCommand resolves Android in-page swipe to content lane',
100100
undefined,
101101
);
102102

103-
assert.deepEqual(calls, [[360, 520, 40, 520, 300]]);
103+
assert.deepEqual(calls, [[340, 520, 60, 520, 300]]);
104104
assert.deepEqual(result, {
105-
x1: 360,
105+
x1: 340,
106106
y1: 520,
107-
x2: 40,
107+
x2: 60,
108108
y2: 520,
109109
preset: 'left',
110110
durationMs: 300,

src/core/scroll-gesture.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,14 @@ export function buildSwipePresetGesturePlan(
109109
options: { platform?: string; marginPx?: number } = {},
110110
): SwipePresetGesturePlan {
111111
const marginPx = options.marginPx ?? 8;
112-
const horizontalLanePercent = options.platform === 'android' ? 65 : 50;
112+
const horizontalLanePercent = 65;
113+
const inPageStartPercent = 85;
114+
const inPageEndPercent = 15;
113115
const [startPercent, endPercent, yPercent] =
114116
preset === 'left'
115-
? [90, 10, horizontalLanePercent]
117+
? [inPageStartPercent, inPageEndPercent, horizontalLanePercent]
116118
: preset === 'right'
117-
? [10, 90, horizontalLanePercent]
119+
? [inPageEndPercent, inPageStartPercent, horizontalLanePercent]
118120
: preset === 'left-edge'
119121
? [99, 15, 50]
120122
: [1, 85, 50];

0 commit comments

Comments
 (0)