From c1ab76609679f374623405d55059c4b28443dd5c Mon Sep 17 00:00:00 2001 From: Fred Liu Date: Tue, 31 May 2016 16:23:51 -0700 Subject: [PATCH] Disable right-swipe from closed position Summary: Disables right-swipe from closed position. Reviewed By: fkgozali Differential Revision: D3368525 fbshipit-source-id: b850458bd088dfda09bbbe4db71b33c3577a2167 --- Libraries/Experimental/SwipeableRow/SwipeableRow.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Libraries/Experimental/SwipeableRow/SwipeableRow.js b/Libraries/Experimental/SwipeableRow/SwipeableRow.js index ee71fa040..169642ef3 100644 --- a/Libraries/Experimental/SwipeableRow/SwipeableRow.js +++ b/Libraries/Experimental/SwipeableRow/SwipeableRow.js @@ -166,7 +166,7 @@ const SwipeableRow = React.createClass({ gestureState: Object, ): boolean { // Decides whether a swipe is responded to by this component or its child - return gestureState.dy < 10 && this._isValidSwipe(gestureState); + return gestureState.dy < 10 && this._isValidSwipe(gestureState); }, _handlePanResponderGrant(event: Object, gestureState: Object): void { @@ -175,7 +175,14 @@ const SwipeableRow = React.createClass({ _handlePanResponderMove(event: Object, gestureState: Object): void { this.props.onSwipeStart(); - this.state.currentLeft.setValue(this._previousLeft + gestureState.dx); + + if (!this._isSwipingRightFromClosedPosition(gestureState)) { + this.state.currentLeft.setValue(this._previousLeft + gestureState.dx); + } + }, + + _isSwipingRightFromClosedPosition(gestureState: Object): boolean { + return this._previousLeft === CLOSED_LEFT_POSITION && gestureState.dx > 0; }, _onPanResponderTerminationRequest(event: Object, gestureState: Object): boolean {