diff --git a/Apps/Examples/Examples/SwiftUI Examples/Testing Examples/MapScrollExample.swift b/Apps/Examples/Examples/SwiftUI Examples/Testing Examples/MapScrollExample.swift new file mode 100644 index 000000000000..39a7ff85745f --- /dev/null +++ b/Apps/Examples/Examples/SwiftUI Examples/Testing Examples/MapScrollExample.swift @@ -0,0 +1,28 @@ +import Foundation +import SwiftUI +@_spi(Experimental) import MapboxMaps + +@available(iOS 14.0, *) +struct MapScrollExample: View { + var body: some View { + List { + Section { + Text("Test Map behaviour inside scroll.") + .font(.title) + .bold() + } + Section { + Map(initialViewport: .followPuck(zoom: 18, bearing: .heading, pitch: 60)) { + Puck2D(bearing: .heading) + }.aspectRatio(1.0, contentMode: .fill) + } + } + } +} + +@available(iOS 14.0, *) +struct MapScrollExample_Previews: PreviewProvider { + static var previews: some View { + MapScrollExample() + } +} diff --git a/Sources/MapboxMaps/Gestures/GestureHandlers/PanGestureHandler.swift b/Sources/MapboxMaps/Gestures/GestureHandlers/PanGestureHandler.swift index 14dbc33214cd..4e43227a6595 100644 --- a/Sources/MapboxMaps/Gestures/GestureHandlers/PanGestureHandler.swift +++ b/Sources/MapboxMaps/Gestures/GestureHandlers/PanGestureHandler.swift @@ -172,7 +172,9 @@ extension PanGestureHandler: UIGestureRecognizerDelegate { shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer ) -> Bool { guard gestureRecognizer === self.gestureRecognizer else { return false } - guard gestureRecognizer.attachedToSameView(as: otherGestureRecognizer) else { return true } + /// The map can be used inside a scroll view which has it's own `PanGestureRecognizer` and they should be mutually exclusive. + /// This will introduce problems for client who are going to implement custom `DragGesture` in SwiftUI, but it's considered as rare case. + /// That's said`gestureRecognizer.attachedToSameView` check is skipped here. switch otherGestureRecognizer { case is UIRotationGestureRecognizer: diff --git a/Tests/MapboxMapsTests/Gestures/GestureHandlers/PanGestureHandlerTests.swift b/Tests/MapboxMapsTests/Gestures/GestureHandlers/PanGestureHandlerTests.swift index 3ee31c6636c0..b07dc470ffeb 100644 --- a/Tests/MapboxMapsTests/Gestures/GestureHandlers/PanGestureHandlerTests.swift +++ b/Tests/MapboxMapsTests/Gestures/GestureHandlers/PanGestureHandlerTests.swift @@ -489,8 +489,4 @@ final class PanGestureHandlerTests: XCTestCase { panGestureHandler.assertNotRecognizedSimultaneously(gestureRecognizer, with: interruptingRecognizers) } - - func testPinchShouldRecognizeSimultaneouslyWithAnyRecognizerAttachedToDifferentView() { - panGestureHandler.assertRecognizedSimultaneously(gestureRecognizer, with: interruptingRecognizers) - } }