-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Improve zoom gesture behavior at minZoom #9626
Improve zoom gesture behavior at minZoom #9626
Conversation
There was a problem hiding this 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.
platform/ios/src/MGLMapView.mm
Outdated
double zoom = log2(newScale); | ||
if (zoom < _mbglMap->getMinZoom()) return; | ||
|
||
double zoom = MAX(log2(newScale), _mbglMap->getMinZoom()); |
There was a problem hiding this comment.
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.)
There was a problem hiding this comment.
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.
1cda20e
to
ea81e04
Compare
This PR makes it easily possible to reach |
@@ -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()); |
There was a problem hiding this comment.
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
ea81e04
to
0cdef85
Compare
Retarget of @danielamitay’s #9595 against the current release branch, with some additional small tweaks.
/cc @fabian-guerra @1ec5