[ios] Cherry pick changes from https://github.com/mapbox/mapbox-gl-native-ios/pull/268/files (#62)
add allowScrollGesturesDuringRotateOrZoom
This commit is contained in:
@@ -733,6 +733,12 @@ MGL_EXPORT
|
||||
*/
|
||||
@property(nonatomic, getter=isPitchEnabled) BOOL pitchEnabled;
|
||||
|
||||
/**
|
||||
A Boolean value that determines whether gestures are anchored to the center coordinate of the map while rotating or zooming.
|
||||
Default value is set to NO.
|
||||
*/
|
||||
@property(nonatomic) BOOL anchorRotateOrZoomGesturesToCenterCoordinate;
|
||||
|
||||
/**
|
||||
A Boolean value that determines whether the user will receive haptic feedback
|
||||
for certain interactions with the map.
|
||||
|
||||
@@ -581,6 +581,9 @@ public:
|
||||
|
||||
// setup interaction
|
||||
//
|
||||
|
||||
self.anchorRotateOrZoomGesturesToCenterCoordinate = NO;
|
||||
|
||||
_pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePanGesture:)];
|
||||
_pan.delegate = self;
|
||||
_pan.maximumNumberOfTouches = 1;
|
||||
@@ -1829,6 +1832,11 @@ public:
|
||||
[self cancelTransitions];
|
||||
|
||||
CGPoint centerPoint = [self anchorPointForGesture:pinch];
|
||||
if (self.anchorRotateOrZoomGesturesToCenterCoordinate) {
|
||||
if (pinch.numberOfTouches != 1 || pinch.state == UIGestureRecognizerStateEnded) {
|
||||
centerPoint = [self contentCenter];
|
||||
}
|
||||
}
|
||||
MGLMapCamera *oldCamera = self.camera;
|
||||
|
||||
self.cameraChangeReasonBitmask |= MGLCameraChangeReasonGesturePinch;
|
||||
@@ -1937,6 +1945,9 @@ public:
|
||||
[self cancelTransitions];
|
||||
|
||||
CGPoint centerPoint = [self anchorPointForGesture:rotate];
|
||||
if (self.anchorRotateOrZoomGesturesToCenterCoordinate) {
|
||||
centerPoint = [self contentCenter];
|
||||
}
|
||||
MGLMapCamera *oldCamera = self.camera;
|
||||
|
||||
self.cameraChangeReasonBitmask |= MGLCameraChangeReasonGestureRotate;
|
||||
@@ -1947,6 +1958,9 @@ public:
|
||||
// Check whether a zoom triggered by a pinch gesture is occurring and if the rotation threshold has been met.
|
||||
if (MGLDegreesFromRadians(self.rotationBeforeThresholdMet) < self.rotationThresholdWhileZooming && self.isZooming && !self.isRotating) {
|
||||
self.rotationBeforeThresholdMet += fabs(rotate.rotation);
|
||||
if (self.anchorRotateOrZoomGesturesToCenterCoordinate) {
|
||||
self.rotationBeforeThresholdMet = 0;
|
||||
}
|
||||
rotate.rotation = 0;
|
||||
return;
|
||||
}
|
||||
@@ -2472,6 +2486,14 @@ public:
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (gestureRecognizer == _pan)
|
||||
{
|
||||
if (self.anchorRotateOrZoomGesturesToCenterCoordinate) {
|
||||
if (self.isZooming || self.isRotating) {
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user