Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Improve zoom gesture behavior at minZoom #9626

Merged

Conversation

friedbunny
Copy link
Contributor

@friedbunny friedbunny commented Jul 26, 2017

Retarget of @danielamitay’s #9595 against the current release branch, with some additional small tweaks.

/cc @fabian-guerra @1ec5

@friedbunny friedbunny added bug iOS Mapbox Maps SDK for iOS labels Jul 26, 2017
@friedbunny friedbunny added this to the ios-v3.6.1 milestone Jul 26, 2017
@friedbunny friedbunny self-assigned this Jul 26, 2017
@friedbunny friedbunny requested review from 1ec5 and fabian-guerra July 26, 2017 23:08
Copy link
Contributor

@1ec5 1ec5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonder if this fixes #4583.

double zoom = log2(newScale);
if (zoom < _mbglMap->getMinZoom()) return;

double zoom = MAX(log2(newScale), _mbglMap->getMinZoom());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might even be unnecessary to compare against getMinZoom(), because mbgl::TransformState already enforces the minimum zoom level. (See also #3842.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is true and, since we’re not otherwise clamping the pinch gesture, I’ve removed this limit in ea81e04924463e86b765f5a76a2d2d7b66ef1521.

@friedbunny friedbunny force-pushed the fb-9595-minzoom-gesture branch from 1cda20e to ea81e04 Compare July 27, 2017 20:42
@friedbunny
Copy link
Contributor Author

friedbunny commented Jul 27, 2017

Wonder if this fixes #4583.

This PR makes it easily possible to reach minZoom using any zoom gesture, but doesn’t change how that limit is calculated (z0.38 on my iPhone 6s). You actually could reach that same minZoom before these changes if you pinched/quick-zoomed slowly or used the two-finger-double-tap gesture.

@@ -1655,9 +1653,9 @@ - (void)handleQuickZoomGesture:(UILongPressGestureRecognizer *)quickZoom
{
CGFloat distance = [quickZoom locationInView:quickZoom.view].y - self.quickZoomStart;

CGFloat newZoom = log2f(self.scale) + (distance / 75);
CGFloat newZoom = MAX(log2f(self.scale) + (distance / 75), _mbglMap->getMinZoom());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: it’s still necessary to clamp this to minZoom because we want to bail if this gesture won’t change the zoom/camera.

- Bail from quick zoom if new zoom is same as old zoom
- Allow pinch gesture at minZoom to still move the map
@friedbunny friedbunny force-pushed the fb-9595-minzoom-gesture branch from ea81e04 to 0cdef85 Compare July 27, 2017 21:34
@friedbunny friedbunny merged commit 0cdef85 into release-ios-v3.6.0-android-v5.1.0 Jul 27, 2017
@friedbunny friedbunny deleted the fb-9595-minzoom-gesture branch July 27, 2017 22:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug iOS Mapbox Maps SDK for iOS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants