Add an option to reverse the direction of the quick zoom gesture (#3587)
This commit is contained in:
@@ -768,6 +768,15 @@ MLN_EXPORT
|
||||
*/
|
||||
@property (nonatomic, getter=isZoomEnabled) BOOL zoomEnabled;
|
||||
|
||||
/**
|
||||
A boolean value that reverses the direction of the quick zoom gesture.
|
||||
|
||||
When this property is set, the zoom-in and zoom-out behavior during the quick
|
||||
zoom gesture (also called one-finger zoom) is reversed, aligning with the
|
||||
behavior in Apple Maps. The default value is `NO`.
|
||||
*/
|
||||
@property (nonatomic, getter=isQuickZoomReversed) BOOL quickZoomReversed;
|
||||
|
||||
/**
|
||||
A Boolean value that determines whether the user may scroll around the map,
|
||||
changing the center coordinate.
|
||||
|
||||
@@ -861,6 +861,7 @@ public:
|
||||
_pinch.delegate = self;
|
||||
[self addGestureRecognizer:_pinch];
|
||||
_zoomEnabled = YES;
|
||||
_quickZoomReversed = NO;
|
||||
|
||||
#if TARGET_IPHONE_SIMULATOR & (TARGET_CPU_X86 | TARGET_CPU_X86_64)
|
||||
if (isM1Simulator) {
|
||||
@@ -2667,6 +2668,8 @@ public:
|
||||
{
|
||||
CGFloat distance = [quickZoom locationInView:quickZoom.view].y - self.quickZoomStart;
|
||||
|
||||
if (self.isQuickZoomReversed) distance = - distance;
|
||||
|
||||
CGFloat newZoom = MAX(log2f(self.scale) + (distance / 75), *self.mbglMap.getBounds().minZoom);
|
||||
|
||||
if ([self zoomLevel] == newZoom) return;
|
||||
@@ -3183,6 +3186,12 @@ static void *windowScreenContext = &windowScreenContext;
|
||||
self.twoFingerTap.enabled = zoomEnabled;
|
||||
}
|
||||
|
||||
- (void)setQuickZoomReversed:(BOOL)quickZoomReversed
|
||||
{
|
||||
MLNLogDebug(@"Setting quickZoomReversed: %@", MLNStringFromBOOL(quickZoomReversed));
|
||||
_quickZoomReversed = quickZoomReversed;
|
||||
}
|
||||
|
||||
- (void)setScrollEnabled:(BOOL)scrollEnabled
|
||||
{
|
||||
MLNLogDebug(@"Setting scrollEnabled: %@", MLNStringFromBOOL(scrollEnabled));
|
||||
|
||||
Reference in New Issue
Block a user