Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map pans at incorrect speed while pinching #10657

Closed
rreusser opened this issue May 7, 2021 · 4 comments · Fixed by #12543
Closed

Map pans at incorrect speed while pinching #10657

rreusser opened this issue May 7, 2021 · 4 comments · Fixed by #12543
Labels

Comments

@rreusser
Copy link
Contributor

rreusser commented May 7, 2021

mapbox-gl-js version: v2.2.0

browser: iOS Safari on iOS 12.5.1

Steps to Trigger Behavior

  1. Begin pinch gesture
  2. Zoom by pinching
  3. Pan
  4. If you zoomed in, the map pans too fast. If you zoomed out, it pans too slowly.
IMG_0016.mp4

Expected Behavior

Map pans at the same speed as centroid of pinch gesture

Actual Behavior

Order of operations (pinch vs. zoom) is perhaps reversed and map panning does not take into account zoom which has occurred since the start of the gesture.

@rreusser
Copy link
Contributor Author

rreusser commented May 7, 2021

See also:

#8345 which notes that the pan does not pan at all (outdated but still open, perhaps?)
#8100 which perhaps introduced this behavior?
#9365 More recent refactoring of gestures

@timsluis
Copy link

timsluis commented Jan 8, 2022

I dove a bit into the code behind this bug and found that it is caused by handle_manager.js on r499. It defines a 'dragOrigin' on the start of a drag event. This causes that the panVec (the amount the map should be panned based on user input) on r526 will be calculated based on the zoom level when the drag event started.

If you are at a low zoom level, zoom in, and then pan left without ending the drag event, the map will pan as if you're still at the low zoom level (which will be very fast as can be seen in the video of @rreusser).

If we change r499 from:

if (eventStarted("drag") && around) {

to:

if ((eventStarted("drag") || zoomDelta) && around) {

the problem is solved, effectively resetting the dragOrigin not only on drag start, but also when there is a delta in the zoom level.

I haven't looked into other (performance) side effects this code change potentially creates. See this as a little help to fix the bug.

(Line numbers are based on the latest release by time of writing: v2.6.1)

@AllenWilliamson
Copy link

Any progress on this issue?

@stepankuzmin
Copy link
Contributor

Good catch, @timsluis! I've made a PR for that #12543

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants