Skip to content

fix(io): auto-scale the default pinch distance to the screen - #481

Merged
gmegidish merged 1 commit into
mobile-next:mainfrom
mobile-kevin:fix-pinch-default-distance
Nov 13, 2026
Merged

gmegidish merged 1 commit into
mobile-next:mainfrom
mobile-kevin:fix-pinch-default-distance

Conversation

@mobile-kevin

Copy link
Copy Markdown
Collaborator

Problem

io pinch defaulted --distance to a fixed 200px. With the 30px start gap, a pinch centered on a narrow screen (iOS ~402pt wide → center x≈201) placed the inner finger at x=-29 and failed every time:

pinch centered at (201,437) with distance 200 would put the left finger at x=-29, past the left edge

So io pinch --direction out (and in) never worked on a phone-sized screen with defaults.

Fix

When no distance is given, derive it from the center: the binding constraint is the left edge (far = startGap + distance must not exceed x), so autoPinchDistance(x) = (x - startGap) * 4/5, floored at a small minimum. This needs only the center — not the screen size, which mobilecli only knows in the natural orientation — so it keeps working on a rotated screen and leaves the far edges to the device like the rest of pinch. An explicit --distance is still honored and still edge-checked. --distance now defaults to 0 (auto).

Tests

  • Unit: autoPinchDistance keeps the inner finger on-screen across centers; pinchActions at a narrow center (x=201) now builds valid actions for both directions; existing default-distance test updated.
  • E2E (simulator): io pinch --direction out/in with defaults succeeds.
  • Verified live: default pinch works on the iPhone simulator and the emulator; an explicit oversized --distance 5000 still errors clearly.

@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

  • Run on-demand review

This review includes 5 billable files and costs up to $1.25.

Or wait 57 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 5a38de2 and b6d1809.

Files selected for processing: 5

  • cli/io.go
  • commands/input.go
  • commands/input_test.go
  • commands/pinch_test.go
  • test/simulator.spec.ts

The default --distance was a fixed 200px. Combined with the 30px start gap,
a pinch centered on a narrow screen (iOS ~402pt wide, center x≈201) put the
inner finger at x=-29 and failed every time with "past the left edge", so
`io pinch --direction out` never worked on a phone-sized screen with defaults.

When no distance is given, derive it from the center so the inner finger stays
on-screen (far = startGap + distance must not exceed x). This needs only the
center, not the screen size, so it keeps working on a rotated screen. An
explicit distance is still honored and still edge-checked.

--distance now defaults to 0 (auto).
@gmegidish
gmegidish force-pushed the fix-pinch-default-distance branch from 0577d91 to b6d1809 Compare November 13, 2026 10:50
@gmegidish
gmegidish merged commit 34e75aa into mobile-next:main Nov 13, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants