Emit coordinates in Native gesture events#4302
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the Native (NativeView) gesture event payload to include both relative (x, y) and absolute (absoluteX, absoluteY) coordinates across web, iOS/macOS, and Android, while keeping the existing “active update suppression” semantics based on pointer state (e.g., pointerInside).
Changes:
- Web: add
x/y/absoluteX/absoluteYto the transformed native event payload and adjust active-update suppression to ignore coordinate churn. - Apple: emit coordinates for NativeView handler events (UIControl + macOS path), and adjust suppression to ignore coordinates.
- Android: emit coordinates for NativeView handler events (converted to DIP) from existing handler position fields.
- Types: extend v3
NativeHandlerDatato include the new coordinate fields.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/react-native-gesture-handler/src/web/handlers/NativeViewGestureHandler.ts | Adds relative/absolute coords to web native events; keeps suppression keyed to pointer state. |
| packages/react-native-gesture-handler/src/v3/hooks/gestures/native/NativeTypes.ts | Extends v3 NativeHandlerData typing with coordinate fields. |
| packages/react-native-gesture-handler/apple/RNGestureHandlerEvents.h | Updates forPointerInside extra-data factory signature to include coords. |
| packages/react-native-gesture-handler/apple/RNGestureHandlerEvents.mm | Adds coords to forPointerInside payload. |
| packages/react-native-gesture-handler/apple/Handlers/RNNativeViewHandler.mm | Emits coords for UIControl and macOS native-view events; keeps suppression keyed to pointer state. |
| packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/events/eventbuilders/NativeGestureHandlerEventDataBuilder.kt | Emits relative/absolute coords (DIP) for native-view events on Android. |
Comments suppressed due to low confidence (1)
packages/react-native-gesture-handler/apple/RNGestureHandlerEvents.mm:174
forPointerInside:withNumberOfTouches:withPointerType:call sites still exist (e.g.apple/Handlers/RNHoverHandler.m), but this implementation removed that selector. Adding a small forwarding overload here will preserve compatibility and prevent build failures while keeping the new coordinate-aware API.
+ (RNGestureHandlerEventExtraData *)forPointerInside:(BOOL)pointerInside
withPosition:(CGPoint)position
withAbsolutePosition:(CGPoint)absolutePosition
withNumberOfTouches:(NSUInteger)numberOfTouches
withPointerType:(NSInteger)pointerType
{
return [[RNGestureHandlerEventExtraData alloc] initWithData:@{
@"pointerInside" : @(pointerInside),
@"x" : @(position.x),
@"y" : @(position.y),
@"absoluteX" : @(absolutePosition.x),
@"absoluteY" : @(absolutePosition.y),
@"numberOfPointers" : @(numberOfTouches),
@"pointerType" : @(pointerType)
}];
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
j-piasecki
reviewed
Jul 8, 2026
| return NO; | ||
| RNGHUITouch *touch = [[event allTouches] anyObject]; | ||
| CGPoint position = touch ? [touch locationInView:sender] : CGPointZero; | ||
| CGPoint absolutePosition = touch ? [touch locationInView:nil] : CGPointZero; |
Member
There was a problem hiding this comment.
Suggested change
| CGPoint absolutePosition = touch ? [touch locationInView:nil] : CGPointZero; | |
| CGPoint absolutePosition = touch ? [touch locationInView:nil] : sender convertPoint:CGPointZero toView:nil]; |
Shouldn't it be something like this?
j-piasecki
approved these changes
Jul 9, 2026
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
This PR adds absolute and relative coordinates to
Nativegesture events. It alsol preserves current cancelation logic - based onpointerInside.Test plan
Add
console.logtoTouchableimplementation and check that coordinates are present.