Skip to content

Commit 0daf75a

Browse files
authored
[RCTTouchHandler] Invert Y coordinate when sending to JS (#1862)
1 parent 914e8b0 commit 0daf75a

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

React/Base/RCTTouchHandler.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,8 @@ - (void)_updateReactTouchAtIndex:(NSInteger)touchIndex
232232
CGPoint rootViewLocation = [_cachedRootView.window.contentView convertPoint:location toView:_cachedRootView];
233233
NSView *touchView = _touchViews[touchIndex];
234234
CGPoint touchViewLocation = [touchView convertPoint:location fromView:nil];
235+
// JavaScript expects coordinates to have (0,0) at top left, unlike the macOS coordinate system
236+
rootViewLocation.y = NSHeight([[_cachedRootView window] frame]) - rootViewLocation.y;
235237
#endif // macOS]
236238

237239
NSMutableDictionary *reactTouch = _reactTouches[touchIndex];

0 commit comments

Comments
 (0)