Skip to content
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
npm-debug.log*
node_modules
lib
.idea/
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ function MyListItem() {
| `onRef` | function | `null` | (optional) receive swipeable component instance reference |
| `onPanAnimatedValueRef` | function | `null` | (optional) receive swipeable pan `Animated.ValueXY` reference for upstream animations |
| `bounceOnMount` | boolean | `false` | (optional) To alert the user that swiping is possible |
| `disable` | boolean | `false` | (optional) Disable swiping |

### Advanced Props

Expand Down Expand Up @@ -134,4 +135,4 @@ or:
MIT

[npm-image]: https://badge.fury.io/js/react-native-swipeable.svg
[npm-url]: https://npmjs.org/package/react-native-swipeable-row
[npm-url]: https://npmjs.org/package/react-native-swipeable-row
18 changes: 16 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export default class Swipeable extends PureComponent {
onRef: PropTypes.func,
onPanAnimatedValueRef: PropTypes.func,
swipeStartMinDistance: PropTypes.number,
disable: PropTypes.bool,

// styles
style: ViewPropTypes.style,
Expand Down Expand Up @@ -152,7 +153,8 @@ export default class Swipeable extends PureComponent {
onRef: noop,
onPanAnimatedValueRef: noop,
swipeStartMinDistance: 15,
bounceOnMount: false
bounceOnMount: false,
disable: false,
};

state = {
Expand Down Expand Up @@ -260,13 +262,21 @@ export default class Swipeable extends PureComponent {
);

_handlePanResponderStart = (event, gestureState) => {
if (this.props.disable) {
return;
}

const {lastOffset, pan} = this.state;

pan.setOffset(lastOffset);
this.props.onSwipeStart(event, gestureState, this);
};

_handlePanResponderMove = (event, gestureState) => {
if (this.props.disable) {
return;
}

const {
leftActionActivationDistance,
leftButtonsActivationDistance,
Expand Down Expand Up @@ -362,6 +372,10 @@ export default class Swipeable extends PureComponent {
};

_handlePanResponderEnd = (event, gestureState) => {
if (this.props.disable) {
return;
}

const {
onLeftActionRelease,
onLeftActionDeactivate,
Expand Down Expand Up @@ -694,4 +708,4 @@ const styles = StyleSheet.create({
content: {
flex: 1
}
});
});