From 7786a550145d8b67969de87f5c6cf592d08c2a7d Mon Sep 17 00:00:00 2001 From: Luke Rhodes Date: Sat, 8 Jul 2017 13:13:31 +1000 Subject: [PATCH 1/2] Fixes unintended side effects caused by #14684 I had fixed this locally but not updated the original pull request, sorry. This commit is working for us in production. --- Libraries/Experimental/SwipeableRow/SwipeableRow.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/Libraries/Experimental/SwipeableRow/SwipeableRow.js b/Libraries/Experimental/SwipeableRow/SwipeableRow.js index bdba02afa8cafb..70986ecb8cd0fe 100644 --- a/Libraries/Experimental/SwipeableRow/SwipeableRow.js +++ b/Libraries/Experimental/SwipeableRow/SwipeableRow.js @@ -72,7 +72,6 @@ const SwipeableRow = createReactClass({ propTypes: { children: PropTypes.any, isOpen: PropTypes.bool, - preventSwipeLeft: PropTypes.bool, preventSwipeRight: PropTypes.bool, maxSwipeDistance: PropTypes.number.isRequired, onOpen: PropTypes.func.isRequired, @@ -110,7 +109,6 @@ const SwipeableRow = createReactClass({ getDefaultProps(): Object { return { isOpen: false, - preventSwipeLeft: false, preventSwipeRight: false, maxSwipeDistance: 0, onOpen: emptyFunction, @@ -339,12 +337,8 @@ const SwipeableRow = createReactClass({ // Ignore swipes due to user's finger moving slightly when tapping _isValidSwipe(gestureState: Object): boolean { - if (this.props.preventSwipeLeft && gestureState.dx < 0) { - return false; - } - if (this.props.preventSwipeRight && gestureState.dx > 0) { - return false; - } + if (this.props.preventSwipeRight && this._previousLeft === CLOSED_LEFT_POSITION && gestureState.dx > 0) return false + return Math.abs(gestureState.dx) > HORIZONTAL_SWIPE_DISTANCE_THRESHOLD; }, From 4dd59d0584605284d2b4c306ee8b5de11bc5609c Mon Sep 17 00:00:00 2001 From: Luke Rhodes Date: Wed, 2 Aug 2017 00:56:07 +1000 Subject: [PATCH 2/2] Amends for eslint-bot --- Libraries/Experimental/SwipeableRow/SwipeableRow.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Libraries/Experimental/SwipeableRow/SwipeableRow.js b/Libraries/Experimental/SwipeableRow/SwipeableRow.js index 70986ecb8cd0fe..42f34a480a7bab 100644 --- a/Libraries/Experimental/SwipeableRow/SwipeableRow.js +++ b/Libraries/Experimental/SwipeableRow/SwipeableRow.js @@ -337,7 +337,9 @@ const SwipeableRow = createReactClass({ // Ignore swipes due to user's finger moving slightly when tapping _isValidSwipe(gestureState: Object): boolean { - if (this.props.preventSwipeRight && this._previousLeft === CLOSED_LEFT_POSITION && gestureState.dx > 0) return false + if (this.props.preventSwipeRight && this._previousLeft === CLOSED_LEFT_POSITION && gestureState.dx > 0) { + return false; + } return Math.abs(gestureState.dx) > HORIZONTAL_SWIPE_DISTANCE_THRESHOLD; },