From 929b2999c45dbc457ec2d3c106bb6750fcba8e45 Mon Sep 17 00:00:00 2001 From: jmstout Date: Tue, 5 May 2015 06:21:11 -0700 Subject: [PATCH] Fix a bug in the Navigator's gesture.edgeHitWidth implementation Summary: Should resolve #1081 cc @ericvicenti Closes https://github.com/facebook/react-native/pull/1082 Github Author: jmstout Test Plan: Imported from GitHub, without a `Test Plan:` line. Revert Plan: This seems legit, but I'm not qualified to review. --- Libraries/CustomComponents/Navigator/Navigator.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Libraries/CustomComponents/Navigator/Navigator.js b/Libraries/CustomComponents/Navigator/Navigator.js index 26c6a46bd..ad9ea0e8a 100644 --- a/Libraries/CustomComponents/Navigator/Navigator.js +++ b/Libraries/CustomComponents/Navigator/Navigator.js @@ -54,7 +54,11 @@ var rebound = require('rebound'); var PropTypes = React.PropTypes; +// TODO: this is not ideal because there is no guarantee that the navigator +// is full screen, hwoever we don't have a good way to measure the actual +// size of the navigator right now, so this is the next best thing. var SCREEN_WIDTH = Dimensions.get('window').width; +var SCREEN_HEIGHT = Dimensions.get('window').height; var SCENE_DISABLED_NATIVE_PROPS = { style: { left: SCREEN_WIDTH, @@ -905,13 +909,17 @@ var Navigator = React.createClass({ var travelDist = isTravelVertical ? gestureState.dy : gestureState.dx; var oppositeAxisTravelDist = isTravelVertical ? gestureState.dx : gestureState.dy; + var edgeHitWidth = gesture.edgeHitWidth; if (isTravelInverted) { currentLoc = -currentLoc; travelDist = -travelDist; oppositeAxisTravelDist = -oppositeAxisTravelDist; + edgeHitWidth = isTravelVertical ? + -(SCREEN_HEIGHT - edgeHitWidth) : + -(SCREEN_WIDTH - edgeHitWidth); } var moveStartedInRegion = gesture.edgeHitWidth == null || - currentLoc < gesture.edgeHitWidth; + currentLoc < edgeHitWidth; var moveTravelledFarEnough = travelDist >= gesture.gestureDetectMovement && travelDist > oppositeAxisTravelDist * gesture.directionRatio;