From 1750d198fa06009ee9967c73a77d1bbf6cf005e6 Mon Sep 17 00:00:00 2001 From: Magalie Caouette Date: Tue, 3 Oct 2017 17:44:43 -0400 Subject: [PATCH] From github nonmerged PR : https://github.com/root-two/react-native-drawer/pull/239 --- README.md | 1 + index.js | 3 +++ 2 files changed, 4 insertions(+) diff --git a/README.md b/README.md index eaa26482..885e9f9e 100644 --- a/README.md +++ b/README.md @@ -112,6 +112,7 @@ This module supports a wide range of drawer styles, and hence has *a lot* of pro - `panThreshold` (Number) `.25` - Ratio of screen width that must be travelled to trigger a drawer open/close. - `panOpenMask` (Number) `null` - Ratio of screen width that is valid for the start of a pan open action. If null -> defaults to `max(.05, closedDrawerOffset)`. - `panCloseMask` (Number) `null` - Ratio of screen width that is valid for the start of a pan close action. If null -> defaults to `max(.05, openDrawerOffset)`. +- `gestureMarginTop` (Number) `0` - Sets the height in dp of top part of the screen where drawer won't capture pan gestures. For example when you have menu button in the top-left corner, you want your gestures to trigger that button, and not the drawer. - `initializeOpen` (Boolean) `false` - Initialize with drawer open? - `side` (String left|right|top|bottom) `left` - which side the drawer should be on. - `useInteractionManager` (Boolean) `false` - if true will run InteractionManager for open/close animations. diff --git a/index.js b/index.js index a56df217..bb3d5e02 100644 --- a/index.js +++ b/index.js @@ -65,6 +65,7 @@ export default class Drawer extends Component { tweenHandler: PropTypes.func, type: PropTypes.oneOf(['overlay', 'static', 'displace']), useInteractionManager: PropTypes.bool, + gestureMarginTop: PropTypes.number, // deprecated panStartCompensation: PropTypes.bool, @@ -81,6 +82,7 @@ export default class Drawer extends Component { panThreshold: 0.25, // @TODO consider rename to panThreshold panOpenMask: null, // defaults to closedDrawerOffset panCloseMask: null, // defaults to openDrawerOffset + gestureMarginTop: 0, tweenHandler: null, tweenDuration: 250, @@ -357,6 +359,7 @@ export default class Drawer extends Component { // Disable if parent or child drawer exist and are open // @TODO make cleaner, generalize to work with 3+ drawers, prop to disable/configure + if ( e.nativeEvent.pageY < this.props.gestureMarginTop ) return false if (this.context.drawer && this.context.drawer._open) return false if (this._childDrawer && this._childDrawer._open) return false