diff options
author | jmkiley <jordan.kiley@mapbox.com> | 2018-01-03 16:24:53 -0800 |
---|---|---|
committer | jmkiley <jordan.kiley@mapbox.com> | 2018-01-03 16:24:53 -0800 |
commit | ee965fc3c597c8a30e3df1586afc49efd7a2b592 (patch) | |
tree | 924eb89e5beb98f47fa209d856a4b367f2847d94 | |
parent | 814c87fbab4608662f90084cff64c27cc5b12bc2 (diff) | |
download | qtlocation-mapboxgl-upstream/jmkiley-horizontal-quickzoom.tar.gz |
[ios] check vertical vs horizontal gesture distanceupstream/jmkiley-horizontal-quickzoom
-rw-r--r-- | platform/ios/src/MGLMapView.mm | 16 |
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; |