[Native] Use correct coordinate space when using native detector#4137
Merged
j-piasecki merged 4 commits intomainfrom May 4, 2026
Merged
[Native] Use correct coordinate space when using native detector#4137j-piasecki merged 4 commits intomainfrom
j-piasecki merged 4 commits intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes coordinate drift for native/V3 detector-based gesture handlers by switching event position calculations from the detector wrapper’s coordinate space to the detector child view’s coordinate space (where user-applied transforms live).
Changes:
- Introduces a
coordinateViewaccessor on iOS (RNGestureHandler) and Android (GestureHandler) to represent the correct coordinate space for reporting event positions. - Updates iOS handler event extra-data builders (position / focal point / anchor point) to use
coordinateViewinstead ofrecognizer.view. - Updates Android event transformation, bounds checking, and point transformation to use
handler.coordinateViewinstead ofhandler.view.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/react-native-gesture-handler/apple/RNGestureHandler.mm | Uses coordinateView for base event position reporting and adds coordinateView implementation. |
| packages/react-native-gesture-handler/apple/RNGestureHandler.h | Declares/document coordinateView for iOS handlers. |
| packages/react-native-gesture-handler/apple/Handlers/RNRotationHandler.m | Uses coordinateView for rotation anchor point. |
| packages/react-native-gesture-handler/apple/Handlers/RNPinchHandler.m | Uses coordinateView for pinch focal point (including per-touch averaging). |
| packages/react-native-gesture-handler/apple/Handlers/RNPanHandler.m | Uses coordinateView for pan position. |
| packages/react-native-gesture-handler/apple/Handlers/RNLongPressHandler.m | Uses coordinateView for long-press position (iOS + macOS paths). |
| packages/react-native-gesture-handler/apple/Handlers/RNHoverHandler.m | Uses coordinateView for hover position. |
| packages/react-native-gesture-handler/apple/Handlers/RNForceTouchHandler.m | Uses coordinateView for force-touch position. |
| packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandlerOrchestrator.kt | Transforms MotionEvents into handler.coordinateView coordinates before delivery. |
| packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandler.kt | Adds coordinateView and uses it for bounds checks and point transforms. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
m-bert
approved these changes
Apr 30, 2026
m-bert
approved these changes
May 4, 2026
Collaborator
m-bert
left a comment
There was a problem hiding this comment.
Looks good 🚀 I think PR description also should mention VirtualGestureDetector, but it's not that important
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Currently, all native handlers are using the coordinate space of the view they are attached to for calculating events. If the handler is attached directly to the view (v1, v2, intercepting detector), this is correct, but when the handler is attached to a wrapper (native detector), the coordinates may drift if the child is transformed.
This PR addresses this by using the child of the native detector as the coordinate space base.
Test plan
Tested on #3124