Skip to content

Commit

Permalink
fix(ios): fix touch handler conflict
Browse files Browse the repository at this point in the history
when a HippyRootView contains another HippyRootView, two touch handlers will work simultaneously
  • Loading branch information
ozonelmy authored and zoomchan-cxj committed Apr 27, 2022
1 parent e0edfae commit 6ae38ca
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion ios/sdk/base/HippyTouchHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,11 @@ - (BOOL)canPreventGestureRecognizer:(__unused UIGestureRecognizer *)preventedGes
return YES;
}
}
if ([preventedGestureRecognizer isKindOfClass:[self class]]) {
UIView *currentHandlerView = [self view];
BOOL canPreventGestureRecognizer = [currentHandlerView isDescendantOfView:gestureView];
return canPreventGestureRecognizer;
}
return NO;
}

Expand All @@ -601,7 +606,14 @@ - (BOOL)canBePreventedByGestureRecognizer:(UIGestureRecognizer *)preventingGestu
// iOS will ask `delegate`'s opinion about this gesture recognizer little bit later.
if (![preventingGestureRecognizer.view isDescendantOfView:_rootView]) {
return NO;
} else {
}
else if ([preventingGestureRecognizer isKindOfClass:[self class]]) {
UIView *currentHandlerView = [self view];
UIView *gestureView = [preventingGestureRecognizer view];
BOOL canPreventGestureRecognizer = [currentHandlerView isDescendantOfView:gestureView];
return !canPreventGestureRecognizer;
}
else {
return ![preventingGestureRecognizer.view isDescendantOfView:self.view];
}
}
Expand Down

0 comments on commit 6ae38ca

Please sign in to comment.