[RCTScrollView] Make ScrollView detect taps on sticky headers
Summary: As per discussion with @nicklockwood in #875, make `RCTScrollView` check its sticky headers for hitTests first. Closes https://github.com/facebook/react-native/pull/1415 Github Author: Brent Vatne <brent.vatne@madriska.com> Test Plan: Have a sticky header in a ScrollView with a Touchable onPress action, scroll a bit after it docks and try tapping, should respond to tap.
This commit is contained in:
parent
76ea00483d
commit
95517fca41
|
@ -223,6 +223,24 @@ CGFloat const ZINDEX_STICKY_HEADER = 50;
|
|||
}
|
||||
}
|
||||
|
||||
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
|
||||
{
|
||||
__block UIView *stickyHeader;
|
||||
|
||||
[_stickyHeaderIndices enumerateIndexesWithOptions:0 usingBlock:^(NSUInteger idx, BOOL *stop) {
|
||||
stickyHeader = [self contentView].reactSubviews[idx];
|
||||
CGPoint convertedPoint = [stickyHeader convertPoint:point fromView:self];
|
||||
|
||||
if ([stickyHeader hitTest:convertedPoint withEvent:event]) {
|
||||
*stop = YES;
|
||||
} else {
|
||||
stickyHeader = nil;
|
||||
}
|
||||
}];
|
||||
|
||||
return stickyHeader ?: [super hitTest:point withEvent:event];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation RCTScrollView
|
||||
|
|
Loading…
Reference in New Issue