Skip to content

Commit dac9e22

Browse files
author
Zack Story
committed
[mainOverlay] use pointerEvents instead of width to conditionally set. Allow styling mainOverlay
1 parent 335d513 commit dac9e22

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

index.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,16 @@ class Drawer extends Component {
165165
break
166166
}
167167

168+
let mainOverlayProps = null
168169
if (this.props.tweenHandler) {
169170
let propsFrag = this.props.tweenHandler(ratio, this.props.side)
170171
mainProps = Object.assign(mainProps, propsFrag.main)
171172
drawerProps = Object.assign(drawerProps, propsFrag.drawer)
173+
mainOverlayProps = propsFrag.mainOverlayProps
172174
}
173175
this.drawer.setNativeProps({style: drawerProps})
174176
this.main.setNativeProps({style: mainProps})
177+
if (mainOverlayProps) this.mainOverlay.setNativeProps({style: mainOverlayProps})
175178
};
176179

177180
shouldOpenDrawer = (dx) => {
@@ -317,9 +320,7 @@ class Drawer extends Component {
317320
this._activeTween = null
318321
this._open = true
319322
this._prevLeft = this._left
320-
if (this.shouldCaptureGestures()) {
321-
if (this.mainOverlay) this.mainOverlay.setNativeProps({ style: { width: this.getMainWidth() }})
322-
}
323+
if (this.shouldCaptureGestures() && this.mainOverlay) this.mainOverlay.setNativeProps({ pointerEvents: 'auto' })
323324
this.props.onOpen()
324325
}
325326
})
@@ -346,7 +347,7 @@ class Drawer extends Component {
346347
this._activeTween = null
347348
this._open = false
348349
this._prevLeft = this._left
349-
if (this.mainOverlay) this.mainOverlay.setNativeProps({ style: { width: 0 }})
350+
if (this.mainOverlay) this.mainOverlay.setNativeProps({ pointerEvents: 'none' })
350351
this.props.onClose()
351352
}
352353
})
@@ -382,8 +383,9 @@ class Drawer extends Component {
382383
{this.props.children}
383384
{this.captureGestures !== false
384385
? <View
386+
pointerEvents={ this.shouldCaptureGestures() ? 'auto' : 'none' }
385387
ref={c => this.mainOverlay = c}
386-
style={styles.mainOverlay}
388+
style={[styles.mainOverlay, this.props.styles && this.props.styles.mainOverlay]}
387389
/>
388390
: null}
389391
</View>
@@ -535,7 +537,7 @@ class Drawer extends Component {
535537

536538
const styles = StyleSheet.create({
537539
mainOverlay: {
538-
width: 0,
540+
right: 0,
539541
left: 0,
540542
top: 0,
541543
bottom: 0,

0 commit comments

Comments
 (0)