Skip to content

Commit d402ea1

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

2 files changed

Lines changed: 24 additions & 2 deletions

File tree

src/__tests__/runtime-interactions.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,26 @@ test('runtime gesture swipe presets use stable viewport lanes', async () => {
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: 20, y: 50 });
638+
assert.deepEqual(pageSwipe.to, { x: 80, y: 50 });
639+
assert.deepEqual(calls, [{ from: { x: 20, y: 50 }, to: { x: 80, y: 50 }, 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/scroll-gesture.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,13 @@ export function buildSwipePresetGesturePlan(
110110
): SwipePresetGesturePlan {
111111
const marginPx = options.marginPx ?? 8;
112112
const horizontalLanePercent = options.platform === 'android' ? 65 : 50;
113+
const inPageStartPercent = options.platform === 'ios' ? 80 : 90;
114+
const inPageEndPercent = options.platform === 'ios' ? 20 : 10;
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)