Skip to content

Commit 335d513

Browse files
author
Zack Story
committed
fix overlay shouldCaptureGestures implementation
1 parent b4be468 commit 335d513

3 files changed

Lines changed: 15 additions & 8 deletions

File tree

examples/RNDrawerExample/src/App.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ export default class App extends Component {
3131
<ControlPanel closeDrawer={this.closeDrawer} />
3232
}
3333
acceptDoubleTap
34-
openDrawerOffset={0.35}
35-
styles={{main: {shadowColor: "#000000", shadowOpacity: 0.3, shadowRadius: 15}}}
34+
styles={{main: {shadowColor: '#000000', shadowOpacity: 0.3, shadowRadius: 15}}}
3635
onOpen={() => {
3736
console.log('onopen')
3837
this.setState({drawerOpen: true})
@@ -42,11 +41,12 @@ export default class App extends Component {
4241
this.setState({drawerOpen: false})
4342
}}
4443
tweenDuration={100}
45-
negotiatePan={true}
4644
panThreshold={0.08}
47-
panOpenMask={0.35}
4845
disabled={this.state.drawerDisabled}
49-
tweenHandler={Drawer.tweenPresets.parallax}>
46+
openDrawerOffset={0.2}
47+
panOpenMask={0.2}
48+
negotiatePan
49+
>
5050
<Main />
5151
</Drawer>
5252
)

index.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ class Drawer extends Component {
189189
return false
190190
};
191191

192+
// @TODO using shouldCaptureGestures in pan responder may be obsolete now that we have overlay
192193
shouldCaptureGestures = () => {
193194
if (this.props.captureGestures === true) return true
194195
if (this.props.captureGestures === 'closed' && this._open === false) return true
@@ -212,11 +213,16 @@ class Drawer extends Component {
212213
};
213214

214215
handleMoveShouldSetPanResponderCapture = (e, gestureState) => {
215-
if (this.shouldCaptureGestures() && this.props.negotiatePan) return this.handleMoveShouldSetPanResponder(e, gestureState)
216+
if (this.shouldCaptureGestures() && this.props.negotiatePan) return this.processMoveShouldSet(e, gestureState)
216217
return false
217218
};
218219

219220
handleMoveShouldSetPanResponder = (e, gestureState) => {
221+
if (!this.shouldCaptureGestures() && this.props.negotiatePan) return this.processMoveShouldSet(e, gestureState)
222+
return false
223+
};
224+
225+
processMoveShouldSet = (e, gestureState) => {
220226
let inMask = this.testPanResponderMask(e, gestureState)
221227
if (!inMask) return false
222228
if (!this.props.acceptPan) return false
@@ -374,7 +380,7 @@ class Drawer extends Component {
374380
style={[this.stylesheet.main, {height: this.getHeight(), width: this.getMainWidth()}]}
375381
>
376382
{this.props.children}
377-
{this.shouldCaptureGestures()
383+
{this.captureGestures !== false
378384
? <View
379385
ref={c => this.mainOverlay = c}
380386
style={styles.mainOverlay}
@@ -497,6 +503,7 @@ class Drawer extends Component {
497503
if (didRotationChange) this._syncAfterUpdate = true
498504
viewport = viewport || this.state.viewport
499505
props = props || this.props
506+
// @TODO code should be methodized and shared with similar calls
500507
this._offsetClosed = props.closedDrawerOffset % 1 === 0 ? props.closedDrawerOffset : props.closedDrawerOffset * viewport.width
501508
this._offsetOpen = props.openDrawerOffset % 1 === 0 ? props.openDrawerOffset : props.openDrawerOffset * viewport.width
502509
this.setState({ viewport })

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-drawer",
3-
"version": "2.0.0-beta3",
3+
"version": "2.0.0-beta4",
44
"description": "React Native Drawer",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)