Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ declare module 'react-native-swipe-gestures' {

export interface GestureRecognizerProps extends ViewProps {
config?: GestureRecognizerConfig;
swipeEnabled?: boolean;
onSwipe?(gestureName: string, gestureState: PanResponderGestureState): void;
onSwipeUp?(gestureState: PanResponderGestureState): void;
onSwipeDown?(gestureState: PanResponderGestureState): void;
Expand Down
9 changes: 7 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,16 @@ class GestureRecognizer extends Component {
onPanResponderTerminate: responderEnd
});
}

componentDidUpdate(prevProps) {
if (this.props.config !== prevProps.config) {
this.swipeConfig = Object.assign(swipeConfig, this.props.config);
}
}

_handleShouldSetPanResponder(evt, gestureState) {
return (
this.props.swipeEnabled &&

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than setting a defaultProp value below, you could simply check if swipeEnabled is not false:
this.props.swipeEnabled !== false

evt.nativeEvent.touches.length === 1 &&
!this._gestureIsClick(gestureState)
);
Expand Down Expand Up @@ -122,4 +123,8 @@ class GestureRecognizer extends Component {
}
}

GestureRecognizer.defaultProps = {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And then you can get rid of this....

swipeEnabled: true,
};

export default GestureRecognizer;