React-native-interactable: How to allow user to swipe right but disallow swipe left

Created on 13 Oct 2017  路  5Comments  路  Source: wix/react-native-interactable

I want to create a smooth right side menu for my app.
In my app, swipe left gesture is used for routing which conflicted to the side menu which made by Interactable.View

Can i just use Interactable.View to allow user to swipe right, but not swipe left ? This problem is confusing me almost 1 week. Please help !!! Thank you so much

My current code:

  <Interactable.View
       ref="tabBarInteractableView"
       horizontalOnly={true}
       onSnap={this.onSnap}
       snapPoints={[{x: 0}, {x: -200}]}
       initialPosition={{x: 0}}>
       .........
  </Interactable.View>

Most helpful comment

Yes, simply use the boundaries prop, e.g. boundaries={{left: -180, right: 0, bounce: 0}}

All 5 comments

@tikkichan4 I wrote a Swipable component that allow you to pass LeftComponent and RightComponent. If you don't pass LeftComponent, then user won't able to swipe left.

https://gist.github.com/tuanmai/22db90a2bebf1fcabb2b4fa8746c740d

@tuanmai it just saved my life. Thank you, tuanmai :D

I don't the see the trick here, is it the boundary prop that is important or snapPoints ?

Yes, simply use the boundaries prop, e.g. boundaries={{left: -180, right: 0, bounce: 0}}

Thank you @wimagguc

Was this page helpful?
0 / 5 - 0 ratings