From d0e40c581d4d709c53f463f65d8e2189725d8d72 Mon Sep 17 00:00:00 2001 From: Michal Aichinger Date: Thu, 15 Oct 2015 06:35:52 -0700 Subject: [PATCH] Fixes a path in touchableHandlerResponderGrant method when touchableGetPressRectOffset method is not present. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: Current code is checking presence of touchableGetPressRectOffset method but fails immediately on trying to get 'left' value of null. Closes https://github.com/facebook/react-native/pull/3438 Reviewed By: @​svcscm Differential Revision: D2545068 Pulled By: @javache fb-gh-sync-id: d16cb46af1fc6eae02f56b2096c2169ce475e022 --- Libraries/Components/Touchable/Touchable.js | 22 +++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/Libraries/Components/Touchable/Touchable.js b/Libraries/Components/Touchable/Touchable.js index 3ff08f736..7b1f56a55 100644 --- a/Libraries/Components/Touchable/Touchable.js +++ b/Libraries/Components/Touchable/Touchable.js @@ -420,16 +420,18 @@ var TouchableMixin = { var positionOnActivate = this.state.touchable.positionOnActivate; var dimensionsOnActivate = this.state.touchable.dimensionsOnActivate; var pressRectOffset = this.touchableGetPressRectOffset ? - this.touchableGetPressRectOffset() : null; - var pressExpandLeft = - pressRectOffset.left != null ? pressRectOffset.left : PRESS_EXPAND_PX; - var pressExpandTop = - pressRectOffset.top != null ? pressRectOffset.top : PRESS_EXPAND_PX; - var pressExpandRight = - pressRectOffset.right != null ? pressRectOffset.right : PRESS_EXPAND_PX; - var pressExpandBottom = - pressRectOffset.bottom != null ? pressRectOffset.bottom : PRESS_EXPAND_PX; - + this.touchableGetPressRectOffset() : { + left: PRESS_EXPAND_PX, + right: PRESS_EXPAND_PX, + top: PRESS_EXPAND_PX, + bottom: PRESS_EXPAND_PX + }; + + var pressExpandLeft = pressRectOffset.left; + var pressExpandTop = pressRectOffset.top; + var pressExpandRight = pressRectOffset.right; + var pressExpandBottom = pressRectOffset.bottom; + var touch = TouchEventUtils.extractSingleTouch(e.nativeEvent); var pageX = touch && touch.pageX; var pageY = touch && touch.pageY;