summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjmkiley <jordan.kiley@mapbox.com>2018-01-03 16:24:53 -0800
committerjmkiley <jordan.kiley@mapbox.com>2018-01-03 16:24:53 -0800
commitee965fc3c597c8a30e3df1586afc49efd7a2b592 (patch)
tree924eb89e5beb98f47fa209d856a4b367f2847d94
parent814c87fbab4608662f90084cff64c27cc5b12bc2 (diff)
downloadqtlocation-mapboxgl-upstream/jmkiley-horizontal-quickzoom.tar.gz
[ios] check vertical vs horizontal gesture distanceupstream/jmkiley-horizontal-quickzoom
-rw-r--r--platform/ios/src/MGLMapView.mm16
1 files changed, 10 insertions, 6 deletions
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index c60e56f808..23810bebf6 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -222,7 +222,7 @@ public:
@property (nonatomic) CLLocationManager *locationManager;
@property (nonatomic) CGFloat scale;
@property (nonatomic) CGFloat angle;
-@property (nonatomic) CGFloat quickZoomStart;
+@property (nonatomic) CGPoint quickZoomStart;
@property (nonatomic, getter=isDormant) BOOL dormant;
@property (nonatomic, readonly, getter=isRotationAllowed) BOOL rotationAllowed;
@property (nonatomic) MGLMapViewProxyAccessibilityElement *mapViewProxyAccessibilityElement;
@@ -1716,7 +1716,7 @@ public:
- (void)handleQuickZoomGesture:(UILongPressGestureRecognizer *)quickZoom
{
if ( ! self.isZoomEnabled) return;
-
+
_mbglMap->cancelTransitions();
if (quickZoom.state == UIGestureRecognizerStateBegan)
@@ -1725,14 +1725,18 @@ public:
self.scale = powf(2, _mbglMap->getZoom());
- self.quickZoomStart = [quickZoom locationInView:quickZoom.view].y;
-
+ self.quickZoomStart = [quickZoom locationInView:quickZoom.view];
+// NSLog(@"Start: %@", self.quickZoomStart);
[self notifyGestureDidBegin];
}
else if (quickZoom.state == UIGestureRecognizerStateChanged)
{
- CGFloat distance = [quickZoom locationInView:quickZoom.view].y - self.quickZoomStart;
-
+ CGFloat distance = [quickZoom locationInView:quickZoom.view].y - self.quickZoomStart.y;
+ CGFloat horizontalDistance = [quickZoom locationInView:quickZoom.view].x - self.quickZoomStart.x;
+
+ // TODO: Still performs quick zoom if you swipe vertically, then horizontally.
+ if (abs(distance) < abs(horizontalDistance)) { return; }
+
CGFloat newZoom = MAX(log2f(self.scale) + (distance / 75), _mbglMap->getMinZoom());
if (_mbglMap->getZoom() == newZoom) return;