From 33ad35206fda10e1028eaf02ac69a017331864e6 Mon Sep 17 00:00:00 2001 From: eisa01 Date: Sat, 23 Aug 2025 19:43:31 +0200 Subject: [PATCH] [drape] Enable shift+swipe to zoom on macOS Catalyst app\ \ Matches functionality in Apple Maps. Discovered while discussing issue #1509\ \ Tested that pinch to zoom still work in iPad Simulator Signed-off-by: eisa01 --- iphone/Maps/Classes/MapViewController.mm | 34 +++++++++++++++--------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/iphone/Maps/Classes/MapViewController.mm b/iphone/Maps/Classes/MapViewController.mm index 00842cfea..b84aba98f 100644 --- a/iphone/Maps/Classes/MapViewController.mm +++ b/iphone/Maps/Classes/MapViewController.mm @@ -908,19 +908,29 @@ NSString *const kAboutSegue = @"Map2About"; CGPoint translation = [recognizer translationInView:self.view]; if (translation.x == 0 && translation.y == 0 && CGPointEqualToPoint(translation, CGPointZero)) return; - self.userTouchesAction = UserTouchesActionDrag; - CGPoint velocity = [recognizer velocityInView:self.view]; - CGFloat velocityX = ABS(velocity.x * 0.001); - velocityX = MAX(1, velocityX); - if (velocityX > 2.5) { - velocityX = 2.5; + + BOOL isShiftPressed = [recognizer modifierFlags] & UIKeyModifierShift; + + if (isShiftPressed) { + self.userTouchesAction = UserTouchesActionScale; + static const CGFloat kScaleFactor = 0.9; + const CGFloat factor = translation.y > 0 ? kScaleFactor : 1 / kScaleFactor; + GetFramework().Scale(factor, [self getZoomPoint], false); + } else { + self.userTouchesAction = UserTouchesActionDrag; + CGPoint velocity = [recognizer velocityInView:self.view]; + CGFloat velocityX = ABS(velocity.x * 0.001); + velocityX = MAX(1, velocityX); + if (velocityX > 2.5) { + velocityX = 2.5; + } + CGFloat velocityY = ABS(velocity.y * 0.001); + velocityY = MAX(1, velocityY); + if (velocityY > 2.5) { + velocityY = 2.5; + } + GetFramework().Scroll((translation.x * velocityX) * -1, (translation.y * velocityY) * -1); } - CGFloat velocityY = ABS(velocity.y * 0.001); - velocityY = MAX(1, velocityY); - if (velocityY > 2.5) { - velocityY = 2.5; - } - GetFramework().Scroll((translation.x * velocityX) * -1, (translation.y * velocityY) * -1); [recognizer setTranslation:CGPointZero inView:self.view]; break; }