Skip to content

Commit 34a8a4d

Browse files
authored
Extreme tilt of the map also moves it considerably [BUG] (#2909)
* Blocks two-finger panning gesture if shove gesture is already in progress.
1 parent 75966bf commit 34a8a4d

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Mapbox welcomes participation and contributions from everyone.
1212

1313
## Bug fixes 🐞
1414
* Mark `BackgroundLayer.backgroundPitchAlignment` as experimental.
15+
* Skip any map scroll (panning) if shove gesture is already in progress preventing camera flying away.
1516

1617
# 11.9.0 December 18, 2024
1718
## Breaking changes ⚠️

plugin-gestures/src/main/java/com/mapbox/maps/plugin/gestures/GesturesPluginImpl.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,11 @@ internal class GesturesPluginImpl : GesturesPlugin, GesturesSettingsBase, MapSty
590590
if (!internalSettings.pinchScrollEnabled && detector.pointersCount > 1) {
591591
return false
592592
}
593+
// Skip any scroll if shove gesture is already in progress
594+
// Without this fix scroll interferences with shove and the camera makes unwanted moves
595+
if (gesturesManager.shoveGestureDetector.isInProgress) {
596+
return false
597+
}
593598

594599
val fromX = detector.focalPoint.x.toDouble()
595600
val fromY = detector.focalPoint.y.toDouble()

plugin-gestures/src/test/java/com/mapbox/maps/plugin/gestures/GesturesPluginTest.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ class GesturesPluginTest {
181181
every { gesturesManager.rotateGestureDetector } returns rotateGestureDetector
182182
every { gesturesManager.standardScaleGestureDetector } returns scaleGestureDetector
183183
every { gesturesManager.shoveGestureDetector } returns shoveGestureDetector
184+
every { shoveGestureDetector.isInProgress } returns false
184185
every { gesturesManager.moveGestureDetector } returns moveGestureDetector
185186
every { mapCameraManagerDelegate.cameraState } returns CameraState(
186187
Point.fromLngLat(0.0, 0.0),
@@ -564,6 +565,22 @@ class GesturesPluginTest {
564565
verify(exactly = 1) { mapTransformDelegate.setGestureInProgress(false) }
565566
}
566567

568+
@OptIn(MapboxExperimental::class)
569+
@Test
570+
fun verifyMoveListenerShoveInProgress() {
571+
every { shoveGestureDetector.isInProgress } returns true
572+
573+
val moveGestureDetector = mockk<MoveGestureDetector>()
574+
every { moveGestureDetector.pointersCount } returns 2
575+
every {
576+
moveGestureDetector.focalPoint
577+
} returns PointF(0.0f, 0.0f)
578+
presenter.moveGestureListener.detector = moveGestureDetector
579+
var handled = presenter.moveGestureListener.onMove(moveGestureDetector, 50.0f, 50.0f)
580+
assertFalse(handled)
581+
verify(exactly = 0) { presenter.mapInteractionDelegate.dispatch(any()) }
582+
}
583+
567584
@Test
568585
fun verifyMoveListenerPinchScrollEnabled() {
569586
presenter.pinchScrollEnabled = true

0 commit comments

Comments
 (0)