react-native-drawer-layout icon indicating copy to clipboard operation
react-native-drawer-layout copied to clipboard

Disable Swipe Gesture to Open

Open JakielaAdam opened this issue 7 years ago • 3 comments

Perhaps I am overlooking a very obvious piece of documentation but I cannot figure out how to disable the swipe gesture. I have looked within this project and DrawerLayoutAndroid. I only want users to be able to open the drawer via a button. Is this possible?

Thank you for your effort on this project.

JakielaAdam avatar Dec 11 '17 21:12 JakielaAdam

Hey @JakielaAdam Unfortunately not, this project aimed to be a Polyfill for the DrawerLayoutAndroid, which doesn't have such a functionality. We decoupled the react-native-drawer-layout-polyfill to be able to do such changes.

I would love to see a PR from you, the main part you would need to change is the _shouldSetPanResponder function. It controls if the user should be able to drag now. Adding a new prop like disableGuesture here and return false early should have the behavior you are searching for.

DanielMSchmidt avatar Dec 11 '17 21:12 DanielMSchmidt

Hi @DanielMSchmidt Thanks for the response. I will consider the PR soon when I have more time.

JakielaAdam avatar Dec 13 '17 14:12 JakielaAdam

Setting drawerLockMode to 'locked-closed' enables you to disable the "swipe to open" gesture.

You can still close the menu by swiping - but if that's not a concern for you, then you can use drawerLockMode.

louiszawadzki avatar Jan 23 '18 09:01 louiszawadzki