Skip to content

Commit 1cc218f

Browse files
authored
Add Panning and Pinching gesture for trackpad (#2460)
1 parent 4b3cee5 commit 1cc218f

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Mapbox welcomes participation and contributions from everyone.
55
## main
66

77
* Reduce MapboxMaps binary size by removing debug symbols. Complete dSYM files are still available in the XCFramework.
8+
* Support panning and pinch gestures on trackpads.
89

910
## 11.10.1 - 25 February, 2025
1011

Sources/MapboxMaps/Gestures/GestureHandlers/PanGestureHandler.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ internal final class PanGestureHandler: GestureHandler, PanGestureHandlerProtoco
5151
super.init(gestureRecognizer: gestureRecognizer)
5252
gestureRecognizer.delegate = self
5353
gestureRecognizer.addTarget(self, action: #selector(handleGesture(_:)))
54+
55+
gestureRecognizer.allowedScrollTypesMask = [.continuous]
5456
}
5557

5658
// Handle gesture events, treating `state == .changed && !isPanning` like `state == .began`,

Sources/MapboxMaps/Gestures/GestureHandlers/PinchGestureHandler.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ internal final class PinchGestureHandler: GestureHandler, PinchGestureHandlerPro
4040
// UIPinchGestureRecognizer sometimes begins with 1 touch.
4141
// If that happens, we ignore it here, but will start handling it
4242
// in .changed if the number of touches increases to 2.
43-
guard gestureRecognizer.numberOfTouches == 2 else {
43+
guard [0, 2].contains(gestureRecognizer.numberOfTouches) else {
4444
return
4545
}
4646
start(with: gestureRecognizer)
@@ -51,7 +51,7 @@ internal final class PinchGestureHandler: GestureHandler, PinchGestureHandlerPro
5151
//
5252
// if a second touch goes down again before the gesture ends, we
5353
// resume and re-capture the initial state
54-
guard gestureRecognizer.numberOfTouches == 2 else {
54+
guard [0, 2].contains(gestureRecognizer.numberOfTouches) else {
5555
initialZoom = nil
5656
gestureRecognizer.scale = 1
5757
return

0 commit comments

Comments
 (0)