From 3be902c3d016770b03dc591b99c32b75e715e8bf Mon Sep 17 00:00:00 2001 From: Jakub Piasecki Date: Mon, 10 Oct 2022 09:48:14 +0200 Subject: [PATCH] Fix missing `begin` event --- .../java/com/swmansion/gesturehandler/PinchGestureHandler.kt | 5 +++++ .../com/swmansion/gesturehandler/RotationGestureHandler.kt | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/android/lib/src/main/java/com/swmansion/gesturehandler/PinchGestureHandler.kt b/android/lib/src/main/java/com/swmansion/gesturehandler/PinchGestureHandler.kt index 6f6afd7255..4f8c1dfe0c 100644 --- a/android/lib/src/main/java/com/swmansion/gesturehandler/PinchGestureHandler.kt +++ b/android/lib/src/main/java/com/swmansion/gesturehandler/PinchGestureHandler.kt @@ -55,6 +55,11 @@ class PinchGestureHandler : GestureHandler() { scaleGestureDetector = ScaleGestureDetector(context, gestureListener) val configuration = ViewConfiguration.get(context) spanSlop = configuration.scaledTouchSlop.toFloat() + + // set the focal point to the position of the first pointer as NaN causes the event not to arrive + this.focalPointX = event.x + this.focalPointY = event.y + begin() } scaleGestureDetector?.onTouchEvent(sourceEvent) diff --git a/android/lib/src/main/java/com/swmansion/gesturehandler/RotationGestureHandler.kt b/android/lib/src/main/java/com/swmansion/gesturehandler/RotationGestureHandler.kt index e86c7447c1..aa6a5b599f 100644 --- a/android/lib/src/main/java/com/swmansion/gesturehandler/RotationGestureHandler.kt +++ b/android/lib/src/main/java/com/swmansion/gesturehandler/RotationGestureHandler.kt @@ -45,6 +45,11 @@ class RotationGestureHandler : GestureHandler() { if (state == STATE_UNDETERMINED) { resetProgress() rotationGestureDetector = RotationGestureDetector(gestureListener) + + // set the anchor to the position of the first pointer as NaN causes the event not to arrive + this.anchorX = event.x + this.anchorY = event.y + begin() } rotationGestureDetector?.onTouchEvent(sourceEvent)