Skip to content

Don't fling the map when the fingers of a pinch lift a moment apart - #2445

Open
DanITman wants to merge 1 commit into
mapbox:mainfrom
DanITman:fix/no-fling-after-pinch
Open

DanITman wants to merge 1 commit into
mapbox:mainfrom
DanITman:fix/no-fling-after-pinch

Conversation

@DanITman

Copy link
Copy Markdown

When a pinch ends with one finger lifted slightly before the other (common in normal use), the pan gesture continues with the remaining finger, which is intended (testTwoToOneNumberOfTouchesTransitionIsSmooth). But if that finger is still moving when it lifts, the pan ends with deceleration, so the map flings toward the last finger.

This change records when a multi-touch pan loses a touch and skips deceleration if the pan ends within 0.3 s of that. Continuing to pan with the remaining finger is unchanged, and so is deceleration for one-finger pans and for a pan that carried on with one finger before being released. No public API changes.

Android doesn't show this: there the fling comes from the platform fling detector, which discards the velocity when the lifting pointer was moving against the other (as in a pinch), and short flings after other gestures are ignored.

The same slide happens in Mapbox's own Studio Preview app on iOS, so it isn't specific to our integration. Showed in sample video below.

Measured on an iPhone 15 Pro (iOS 26.5.2): at the end of 14 pinches, the second finger lifted 0–33 ms after the first while the pan was moving at 13–372 pt/s, so each one decelerated. Deliberate one-finger flings in the same session were 585–4,141 pt/s. With this change applied to 11.32.0 in our app, pinches end without sliding, panning on with one finger still works, and one-finger flings are unchanged.

Two finger pinch reliase flick issue on Mapbox App:
https://youtube.com/shorts/mrx2qiOdGAc?feature=share

You can see the issue at the end of almost every zoom two finger gesture. If you don't release exactly at the same time you get a slight pan event that likely wasn't intended by the user.

Two finger pinch release and flick fixed:
https://youtube.com/shorts/ow4ZupCnZQI?feature=share

You will see at the end of the two finger pinch gesture, the app no longer has that slight fling event after the release of the second finger.

Pull request checklist:

  • Describe the changes in this PR, especially public API changes.
  • Include before/after visuals or gifs if this PR includes visual changes.
  • Write tests for all new functionality. Put tests in correct Test Plan (Unit, Integration, All)
    • PanGestureHandlerTests.testPanEndingRightAfterAFingerLiftsFromMultiTouchDoesNotDecelerate (fails without the change)
    • PanGestureHandlerTests.testPanContinuedWithOneFingerAfterMultiTouchStillDecelerates
    • Ran PanGestureHandlerTests (30/30), PinchGestureHandlerTests (17/17), GestureManagerTests (29/29) and InterruptDecelerationGestureHandlerTests (3/3) through the Swift package on an iOS 27 simulator. SwiftLint is clean on the changed files.
  • Add documentation comments for any added or updated public APIs. (none added)
  • Add any new public, top-level symbols to the DocC custom catatlog (none added)
  • Add a changelog entry to to bottom of the relevant section (typically the ## main heading near the top).
  • Update the guides (internal access only), README.md, and DEVELOPING.md if their contents are impacted by these changes. (not affected)
  • If this PR is a v10.[version] release branch fix / enhancement, merge it to main first and then port to v10.[version] release branch. (not applicable)

PRs must be submitted under the terms of our Contributor License Agreement CLA.

@DanITman
DanITman requested a review from a team as a code owner October 13, 2026 23:55
@CLAassistant

CLAassistant commented Oct 13, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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