-
Notifications
You must be signed in to change notification settings - Fork 69
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
Cancel swipe #60
Comments
Use the |
Hi rubycon! |
Yes, the event is fired after the change but if you update the index in response, SideSwipe won't start rendering the transition. It might look a bit hacky but works great and render nice on Android and iOS for me: <SideSwipe
// ...
index={this.state.index}
onIndexChange={index => {
const prevIndex = this.state.index;
// update your index state in any case, to keep the value coherent
// with the internal state of SideSwipe. This won't trigger another onIndexChange.
this.setState({index}, () => {
// then correct the index if needed.
if(isNotAllowed(index))
this.setState({index: prevIndex});
})
}}
/> If you want to deny the move you can use the shouldCapture={gestureState => {
if(gestureState.dx > 0 && isNotAllowed(this.index + 1))
return false;
if(gestureState.dx < 0 && isNotAllowed(this.index - 1))
return false;
return true;
}} |
Thank you very much, with that I can work perfectly. |
I'm having a similar issue; where I want to make sure that the user cannot interact with the side-swipe component, but returning false within |
How can I do to prevent the user from moving around the different views? and manage the current changes Index for my own.
Basically what I want is to cancel the swipe.
Can someone help me?
The text was updated successfully, but these errors were encountered: