From 6c25a681fa2509b6f7b172945627bebd0abf42db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82?= Date: Fri, 24 Jul 2026 12:35:17 +0200 Subject: [PATCH 1/2] Fix Android --- .../com/swmansion/gesturehandler/core/GestureHandler.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandler.kt b/packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandler.kt index 4dab48acc4..c0ca5127c9 100644 --- a/packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandler.kt +++ b/packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandler.kt @@ -477,10 +477,15 @@ open class GestureHandler { } private fun dispatchTouchUpEvent(event: MotionEvent, sourceEvent: MotionEvent) { + val pointerId = event.getPointerId(event.actionIndex) + + if (trackedPointers[pointerId] == null) { + return + } + extractAllPointersData() changedTouchesPayload = null touchEventType = RNGestureHandlerTouchEvent.EVENT_TOUCH_UP - val pointerId = event.getPointerId(event.actionIndex) val offsetX = sourceEvent.rawX - sourceEvent.x val offsetY = sourceEvent.rawY - sourceEvent.y From 3f853e07aab24c62308a41097cf03767adae5f8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82?= Date: Fri, 24 Jul 2026 12:51:32 +0200 Subject: [PATCH 2/2] Fix iOS --- .../apple/RNGestureHandlerPointerTracker.mm | 44 ++++++++++++++----- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/packages/react-native-gesture-handler/apple/RNGestureHandlerPointerTracker.mm b/packages/react-native-gesture-handler/apple/RNGestureHandlerPointerTracker.mm index e064d0994c..2f06e15dbc 100644 --- a/packages/react-native-gesture-handler/apple/RNGestureHandlerPointerTracker.mm +++ b/packages/react-native-gesture-handler/apple/RNGestureHandlerPointerTracker.mm @@ -116,18 +116,25 @@ - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event _eventType = RNGHTouchEventTypePointerDown; NSDictionary *data[touches.count]; + int changedCount = 0; for (int i = 0; i < [touches count]; i++) { RNGHUITouch *touch = [[touches allObjects] objectAtIndex:i]; int index = [self registerTouch:touch]; - if (index >= 0) { - _trackedPointersCount++; + + if (index < 0) { + continue; } - data[i] = [self extractPointerData:index forTouch:touch]; + _trackedPointersCount++; + data[changedCount++] = [self extractPointerData:index forTouch:touch]; + } + + if (changedCount == 0) { + return; } - _changedPointersData = [[NSArray alloc] initWithObjects:data count:[touches count]]; + _changedPointersData = [[NSArray alloc] initWithObjects:data count:changedCount]; // extract all touches last to include the ones that were just added [self extractAllTouches]; [self sendEvent]; @@ -142,14 +149,24 @@ - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event _eventType = RNGHTouchEventTypePointerMove; NSDictionary *data[touches.count]; + int changedCount = 0; for (int i = 0; i < [touches count]; i++) { RNGHUITouch *touch = [[touches allObjects] objectAtIndex:i]; int index = [self findTouchIndex:touch]; - data[i] = [self extractPointerData:index forTouch:touch]; + + if (index < 0) { + continue; + } + + data[changedCount++] = [self extractPointerData:index forTouch:touch]; } - _changedPointersData = [[NSArray alloc] initWithObjects:data count:[touches count]]; + if (changedCount == 0) { + return; + } + + _changedPointersData = [[NSArray alloc] initWithObjects:data count:changedCount]; [self extractAllTouches]; [self sendEvent]; } @@ -166,18 +183,25 @@ - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event _eventType = RNGHTouchEventTypePointerUp; NSDictionary *data[touches.count]; + int changedCount = 0; for (int i = 0; i < [touches count]; i++) { RNGHUITouch *touch = [[touches allObjects] objectAtIndex:i]; int index = [self unregisterTouch:touch]; - if (index >= 0) { - _trackedPointersCount--; + + if (index < 0) { + continue; } - data[i] = [self extractPointerData:index forTouch:touch]; + _trackedPointersCount--; + data[changedCount++] = [self extractPointerData:index forTouch:touch]; + } + + if (changedCount == 0) { + return; } - _changedPointersData = [[NSArray alloc] initWithObjects:data count:[touches count]]; + _changedPointersData = [[NSArray alloc] initWithObjects:data count:changedCount]; [self sendEvent]; }