satya164 / react-native-tab-view

A cross-platform Tab View component for React Native
MIT License
5.14k stars 1.07k forks source link

Disabling swipe gestures on certain tabs #400

Closed danbenn closed 6 years ago

danbenn commented 6 years ago

Expected behaviour

I'd like to be able to disable swipe to change tabs for a specific tab.

Reason: one of my tabs has a Tinder-style card swiper, and the gestures for swiping on the cards and changing tabs can conflict.

The swipe gesture is a fast and easy way for a user to switch tabs, so it would be useful to preserve this feature for the rest of my tabs.

Actual behaviour

The API for <TabViewPagerPan /> has a swipeEnabled prop but no way to disable for specific tabs.

What have you tried

Sorry, I have no idea how I could circumvent this. Is there some gesture "filter" that will funnel gestures only to a specific component?

I read the source code for TabViewPagerPan but couldn't find anything to solve this problem. I also carefully searched previous issues in this repo, and couldn't find anything similar.

Thank you for your help!

satya164 commented 6 years ago

Have you tried setting swipeEnabled prop based on your state?

danbenn commented 6 years ago

Perfect. Thank you so much!