From 48117ce6c4350cd1336f0d37608d2f2829dd3c29 Mon Sep 17 00:00:00 2001 From: Jeff Berg Date: Wed, 20 Jan 2016 20:35:18 -0800 Subject: [PATCH] Fix TouchNativeFeedback so that the ripple starts from where a person touches Summary: It needs the touch coordinates for with-in the element, not for on the page. Closes https://github.com/facebook/react-native/pull/5400 Reviewed By: svcscm Differential Revision: D2848834 Pulled By: androidtrunkagent fb-gh-sync-id: 88cf0fd7bd2332eb3db835b26438064412c8358c --- Libraries/Components/Touchable/Touchable.js | 4 +++- .../Components/Touchable/TouchableNativeFeedback.android.js | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Libraries/Components/Touchable/Touchable.js b/Libraries/Components/Touchable/Touchable.js index c8d67ab3e..f9d8e1e43 100644 --- a/Libraries/Components/Touchable/Touchable.js +++ b/Libraries/Components/Touchable/Touchable.js @@ -623,7 +623,9 @@ var TouchableMixin = { var touch = TouchEventUtils.extractSingleTouch(e.nativeEvent); var pageX = touch && touch.pageX; var pageY = touch && touch.pageY; - this.pressInLocation = {pageX: pageX, pageY: pageY}; + var locationX = touch && touch.locationX; + var locationY = touch && touch.locationY; + this.pressInLocation = {pageX, pageY, locationX, locationY}; }, _getDistanceBetweenPoints: function (aX, aY, bX, bY) { diff --git a/Libraries/Components/Touchable/TouchableNativeFeedback.android.js b/Libraries/Components/Touchable/TouchableNativeFeedback.android.js index 240b2482a..ec3850c6b 100644 --- a/Libraries/Components/Touchable/TouchableNativeFeedback.android.js +++ b/Libraries/Components/Touchable/TouchableNativeFeedback.android.js @@ -141,7 +141,7 @@ var TouchableNativeFeedback = React.createClass({ touchableHandleActivePressIn: function() { this.props.onPressIn && this.props.onPressIn(); this._dispatchPressedStateChange(true); - this._dispatchHotspotUpdate(this.pressInLocation.pageX, this.pressInLocation.pageY); + this._dispatchHotspotUpdate(this.pressInLocation.locationX, this.pressInLocation.locationY); }, touchableHandleActivePressOut: function() {