Skip to content

Commit f1160c0

Browse files
authoredAug 14, 2023
[RCTTouchHandler] Add a small optimization to coordinate conversion (microsoft#1902)
1 parent 9926513 commit f1160c0

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed
 

‎React/Base/RCTTouchHandler.m

+2-3
Original file line numberDiff line numberDiff line change
@@ -229,11 +229,10 @@ - (void)_updateReactTouchAtIndex:(NSInteger)touchIndex
229229
NSEvent *nativeTouch = _nativeTouches[touchIndex];
230230
CGPoint location = nativeTouch.locationInWindow;
231231
RCTAssert(_cachedRootView, @"We were unable to find a root view for the touch");
232-
CGPoint rootViewLocation = [_cachedRootView.window.contentView convertPoint:location toView:_cachedRootView];
232+
CGPoint rootViewLocation = [_cachedRootView convertPoint:location fromView:nil];
233+
233234
NSView *touchView = _touchViews[touchIndex];
234235
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;
237236
#endif // macOS]
238237

239238
NSMutableDictionary *reactTouch = _reactTouches[touchIndex];

0 commit comments

Comments
 (0)
Please sign in to comment.