Skip to content

Commit

Permalink
chore: unify RNSScreenStack#isInGestureResponseDistance:topScreen:
Browse files Browse the repository at this point in the history
method
  • Loading branch information
kkafar committed May 13, 2022
1 parent 74d4bae commit 2e74e5c
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions ios/RNSScreenStack.mm
Original file line number Diff line number Diff line change
Expand Up @@ -751,12 +751,20 @@ - (BOOL)isInGestureResponseDistance:(UIGestureRecognizer *)gestureRecognizer top
if (isRTL) {
x = _controller.view.frame.size.width - x;
}

// see: https://github.com/software-mansion/react-native-screens/pull/1442/commits/c0413bddadc1023022d3d390373321632ad3539d
// this prop is always default initialized so we do not expect any nils
float start = [gestureResponseDistanceValues[@"start"] floatValue];
float end = [gestureResponseDistanceValues[@"end"] floatValue];
float top = [gestureResponseDistanceValues[@"top"] floatValue];
float bottom = [gestureResponseDistanceValues[@"bottom"] floatValue];

// we check if any of the constraints are violated and return NO if so
return !(
(gestureResponseDistanceValues[@"start"] && x < [gestureResponseDistanceValues[@"start"] floatValue]) ||
(gestureResponseDistanceValues[@"end"] && x > [gestureResponseDistanceValues[@"end"] floatValue]) ||
(gestureResponseDistanceValues[@"top"] && y < [gestureResponseDistanceValues[@"top"] floatValue]) ||
(gestureResponseDistanceValues[@"bottom"] && y > [gestureResponseDistanceValues[@"bottom"] floatValue]));
(start != -1 && x < start) ||
(end != -1 && x > end) ||
(top != -1 && y < top) ||
(bottom != -1 && y > bottom));
}

#ifdef RN_FABRIC_ENABLED
Expand Down

0 comments on commit 2e74e5c

Please sign in to comment.