Skip to content

Commit

Permalink
Fabric: Custom [RCTViewComponentView hitTest:] that takes `pointerE…
Browse files Browse the repository at this point in the history
…vents` into an account

Summary:
@public
In RN we have special `pointerEvents` prop that controls whether the View can be the target of touch events.
This is a pretty straight-forward implementation of that.

Reviewed By: sahrens

Differential Revision: D9688877

fbshipit-source-id: 1524647b0a33e4dd14563f531d636469bf3bdef7
  • Loading branch information
shergin authored and gengjiawen committed Sep 14, 2018
1 parent 6d64519 commit 7f6f138
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,22 @@ - (void)updateLayoutMetrics:(LayoutMetrics)layoutMetrics
[self invalidateLayer];
}

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
auto viewProps = *std::static_pointer_cast<const ViewProps>(_props);
switch (viewProps.pointerEvents) {
case PointerEventsMode::Auto:
return [super hitTest:point withEvent:event];
case PointerEventsMode::None:
return nil;
case PointerEventsMode::BoxOnly:
return [self pointInside:point withEvent:event] ? self : nil;
case PointerEventsMode::BoxNone:
UIView *view = [super hitTest:point withEvent:event];
return view != self ? view : nil;
}
}

static RCTCornerRadii RCTCornerRadiiFromBorderRadii(BorderRadii borderRadii) {
return RCTCornerRadii {
.topLeft = (CGFloat)borderRadii.topLeft,
Expand Down

0 comments on commit 7f6f138

Please sign in to comment.