root-two / react-native-drawer

React Native Drawer
MIT License
2.54k stars 390 forks source link

Doesn't play well with <Modal /> #326

Open tybro0103 opened 7 years ago

tybro0103 commented 7 years ago

When one of my content views renders a <Modal /> the drawer will still open and close with swipe gestures. Can't actually see it happening because the modal covers it up, but if you swipe over the modal and then close it, the drawer will then be open under it. Would like to see interaction with the drawer disabled while a modal is open. Perhaps there's a way to do this already? If it matters, here's my drawer props:

const drawerConfig = {
  type: 'static',
  openDrawerOffset: 0.1,
  tweenDuration: 300,
  tweenEasing: 'easeInOutCubic',
  captureGestures: 'open',
  negotiatePan: true,
  tapToClose: true,
  panOpenMask: 0.1,
  panThreshold: 0.25,
  styles: {
    main: {shadowColor: '#000000', shadowOpacity: 0.8, shadowRadius: 10},
    mainOverlay: {backgroundColor: 'white', opacity: 0},
  },
  tweenHandler: (percent) => ({
    drawer: Drawer.tweenPresets.parallax(percent).drawer,
    mainOverlay: { opacity: percent * 0.8 },
  }),
};
roycclu commented 6 years ago

Experiencing the same problem. Here, swipe motion is still captured by drawer under the modal. @tybro0103 did you find a fix to this eventually?

tybro0103 commented 6 years ago

@roycclu I resorted to tracking whether or not there was a modal open and disabling the drawer:

<Drawer disabled={isModalOpen} />

...which is a bit messier than it seems at first, cuz the context in which you're rendering a modal is usually a different context than where you're rendering the drawer. You need to come up with a way to determine if there is any modal open anywhere in your app.

roycclu commented 6 years ago

@tybro0103 Thanks man. Works like magic. Not very elegant, but gets the job done. Some kind of state store or react context should serve for global tracking. For me they happen to be on same component, so this was a easy fix. Thanks!