diff --git a/Libraries/Experimental/SwipeableRow/SwipeableRow.js b/Libraries/Experimental/SwipeableRow/SwipeableRow.js index 769044185..bdba02afa 100644 --- a/Libraries/Experimental/SwipeableRow/SwipeableRow.js +++ b/Libraries/Experimental/SwipeableRow/SwipeableRow.js @@ -72,6 +72,8 @@ const SwipeableRow = createReactClass({ propTypes: { children: PropTypes.any, isOpen: PropTypes.bool, + preventSwipeLeft: PropTypes.bool, + preventSwipeRight: PropTypes.bool, maxSwipeDistance: PropTypes.number.isRequired, onOpen: PropTypes.func.isRequired, onClose: PropTypes.func.isRequired, @@ -108,6 +110,8 @@ const SwipeableRow = createReactClass({ getDefaultProps(): Object { return { isOpen: false, + preventSwipeLeft: false, + preventSwipeRight: false, maxSwipeDistance: 0, onOpen: emptyFunction, onClose: emptyFunction, @@ -335,6 +339,12 @@ 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; + } return Math.abs(gestureState.dx) > HORIZONTAL_SWIPE_DISTANCE_THRESHOLD; },