Reputation: 33
Can someone please tell me what is wrong with this code? When I run the simulator it runs fine but when I swipe to bring up the content it doesn't show up. The drawer wont work. What am I doing wrong?
import React, { Component } from 'react';
import { Drawer } from 'native-base';
import { Navigator, View } from 'react-native';
export default class DrawerExample extends Component {
constructor(props) {
super(props);
this.state = {
toggled: false,
store: {},
theme: null
};
}
toggleDrawer() {
this.state.toggled ? this._drawer.close() : this._drawer.open();
}
openDrawer() {
this.setState({toggled: true});
}
closeDrawer() {
this.setState({toggled: false});
}
renderScene(route, navigator) {
switch(route) {
default: return null;
}
}
configureScene(route, routeStack) {
return Navigator.SceneConfigs.PushFromRight;
}
render() {
return (
<Drawer
ref={(ref) => this._drawer = ref}
type='displace'
content={<View style={{backgroundColor: '#000', height: 1000}} />}
onClose={this.closeDrawer.bind(this)}
onOpen={this.openDrawer.bind(this)}
openDrawerOffset={100}
>
<Navigator
ref={(ref) => this._navigator = ref}
configureScene={this.configureScene.bind(this)}
renderScene={this.renderScene.bind(this)}
/>
</Drawer>
);
}
}
Upvotes: 2
Views: 3251
Reputation: 446
You can achieve this with panOpenMask={<value>}
.
I tested it with a value of .25
.
The API says:
panOpenMask
(Number)null
- Ratio of screen width that is valid for the start of a pan open action. If null -> defaults tomax(.05, closedDrawerOffset)
EDIT:
My full code (on my own project) is:
<Drawer
ref={(ref) => { this._drawer = ref; }}
content={ navigationView }
side="right"
panOpenMask={.25}
>
Upvotes: 9