summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjmkiley <jordan.kiley@mapbox.com>2019-06-14 17:09:49 -0700
committerjmkiley <jordan.kiley@mapbox.com>2019-08-02 13:13:08 -0700
commit323c3eb447f5db53d4957e28de5a45b1d65d3bf8 (patch)
tree2fb0f9b0a325d815d16e92df46e014e0a4bdca1c
parentff798083acd2b53b49564da365da6eb94453b898 (diff)
downloadqtlocation-mapboxgl-323c3eb447f5db53d4957e28de5a45b1d65d3bf8.tar.gz
[ios] added array of activegesturerecognizers
-rw-r--r--platform/ios/src/MGLMapView.mm21
1 files changed, 10 insertions, 11 deletions
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index f62bf14c80..94ec8df4d3 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -215,6 +215,8 @@ public:
@property (nonatomic) UIRotationGestureRecognizer *rotate;
@property (nonatomic) UILongPressGestureRecognizer *quickZoom;
@property (nonatomic) UIPanGestureRecognizer *twoFingerDrag;
+// jk
+@property (nonatomic) NSMutableArray<UIGestureRecognizer *> *activeGestureRecognizers;
@property (nonatomic) UIInterfaceOrientation currentOrientation;
@property (nonatomic) UIInterfaceOrientationMask applicationSupportedInterfaceOrientations;
@@ -607,6 +609,8 @@ public:
[_singleTapGestureRecognizer requireGestureRecognizerToFail:_quickZoom];
[self addGestureRecognizer:_singleTapGestureRecognizer];
+ _activeGestureRecognizers = [[NSMutableArray alloc] init];
+
// observe app activity
//
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(willTerminate) name:UIApplicationWillTerminateNotification object:nil];
@@ -1619,19 +1623,12 @@ public:
MGLMapCamera *oldCamera = self.camera;
self.cameraChangeReasonBitmask |= MGLCameraChangeReasonGesturePinch;
-
- // jk - this stops the map from rotating at all
-// if ( self.rotateEnabled ) {
-// self.currentRotation += self.rotate.rotation;
-// if ( std::abs(self.currentRotation) < 20 ) {
-// self.rotate.rotation = 0;
-// }
-// }
if (pinch.state == UIGestureRecognizerStateBegan)
{
self.scale = powf(2, [self zoomLevel]);
+ [self.activeGestureRecognizers addObject:pinch];
[self notifyGestureDidBegin];
}
else if (pinch.state == UIGestureRecognizerStateChanged)
@@ -1660,6 +1657,8 @@ public:
}
else if (pinch.state == UIGestureRecognizerStateEnded || pinch.state == UIGestureRecognizerStateCancelled)
{
+ [self.activeGestureRecognizers removeObject:pinch];
+
CGFloat velocity = pinch.velocity;
if (isnan(velocity))
{
@@ -1736,7 +1735,7 @@ public:
}
self.shouldTriggerHapticFeedbackForCompass = NO;
-
+ [self.activeGestureRecognizers addObject:rotate];
[self notifyGestureDidBegin];
}
else if (rotate.state == UIGestureRecognizerStateChanged)
@@ -1744,8 +1743,7 @@ public:
// // jk - once it does start rotating, it'd jumpy. Also, this happens whenever I rotate, not just when zooming.
self.currentRotation += self.rotate.rotation;
- NSLog(@"PINCH: %f", self.scale);
- if ( std::abs(self.currentRotation) < 20 && std::abs(self.scale) > 20 ) {
+ if ( std::abs(self.currentRotation) < 50 && [self.activeGestureRecognizers containsObject:self.pinch]) {
NSLog(@"ROTATION: %f", rotate.rotation);
return;
}
@@ -1789,6 +1787,7 @@ public:
}
else if (rotate.state == UIGestureRecognizerStateEnded || rotate.state == UIGestureRecognizerStateCancelled)
{
+ [self.activeGestureRecognizers removeObject:rotate];
CGFloat velocity = rotate.velocity;
CGFloat decelerationRate = self.decelerationRate;
self.currentRotation = 0;