Skip to content
This repository was archived by the owner on Nov 11, 2024. It is now read-only.

Commit 80ae3f3

Browse files
committed
fix: hitTest in RCTScrollView
It now takes contentOffset into account.
1 parent b7751ff commit 80ae3f3

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

React/Views/ScrollView/RCTScrollView.m

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -718,8 +718,12 @@ - (void)sendScrollEventWithName:(NSString *)eventName
718718

719719
- (NSView *)hitTest:(NSPoint)point
720720
{
721-
// TODO: adjust "point" based on scroll offset
722-
return [self.documentView hitTest:point];
721+
// Note: This assumes "contentView.clipsToBounds" is YES.
722+
if (!CGRectContainsPoint(self.frame, point)) {
723+
return nil;
724+
}
725+
NSPoint contentOffset = self.contentView.bounds.origin;
726+
return [self.documentView hitTest:(NSPoint){point.x + contentOffset.x, point.y + contentOffset.y}];
723727
}
724728

725729
@end

0 commit comments

Comments
 (0)