Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disable gestures hotfix #110

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
22 changes: 22 additions & 0 deletions Swiper.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ class Swiper extends Component {
this.initializePanResponder()
}

get isStopAnyGestures() {
return !this.props.verticalSwipe && !this.props.horizontalSwipe
}

shouldComponentUpdate = (nextProps, nextState) => {
const { props, state } = this
const propsChanged = (
Expand Down Expand Up @@ -123,6 +127,10 @@ class Swiper extends Component {
onMoveShouldSetPanResponder: (event, gestureState) => false,

onMoveShouldSetPanResponderCapture: (evt, gestureState) => {
if (this.isStopAnyGestures) {
return false
}

const isVerticalSwipe = Math.sqrt(
Math.pow(gestureState.dx, 2) < Math.pow(gestureState.dy, 2)
)
Expand Down Expand Up @@ -153,6 +161,10 @@ class Swiper extends Component {
onPanResponderMove = (event, gestureState) => {
this.props.onSwiping(this._animatedValueX, this._animatedValueY)

if (this.isStopAnyGestures) {
return
}

let { overlayOpacityHorizontalThreshold, overlayOpacityVerticalThreshold } = this.props
if (!overlayOpacityHorizontalThreshold) {
overlayOpacityHorizontalThreshold = this.props.horizontalThreshold
Expand Down Expand Up @@ -206,6 +218,11 @@ class Swiper extends Component {

onPanResponderGrant = (event, gestureState) => {
this.props.dragStart && this.props.dragStart()

if (this.isStopAnyGestures) {
return
}

if (!this.state.panResponderLocked) {
this.state.pan.setOffset({
x: this._animatedValueX,
Expand Down Expand Up @@ -244,6 +261,11 @@ class Swiper extends Component {

onPanResponderRelease = (e, gestureState) => {
this.props.dragEnd && this.props.dragEnd()

if (this.isStopAnyGestures) {
return
}

if (this.state.panResponderLocked) {
this.state.pan.setValue({
x: 0,
Expand Down