mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-02-10 09:13:43 +08:00
Handle back button properly when the drawer is open
This commit is contained in:
committed by
satyajit.happy
parent
ef56c1a980
commit
c8d49948b1
@@ -60,6 +60,24 @@ export default class DrawerView extends React.PureComponent {
|
||||
|
||||
drawerGestureRef = React.createRef();
|
||||
|
||||
_handleDrawerStateChange = newState => {
|
||||
if (newState === 'Idle') {
|
||||
if (!this.props.navigation.state.isDrawerIdle) {
|
||||
this.props.navigation.dispatch({
|
||||
type: DrawerActions.MARK_DRAWER_IDLE,
|
||||
key: this.props.navigation.state.key,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (this.props.navigation.state.isDrawerIdle) {
|
||||
this.props.navigation.dispatch({
|
||||
type: DrawerActions.MARK_DRAWER_ACTIVE,
|
||||
key: this.props.navigation.state.key,
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
_handleDrawerOpen = () => {
|
||||
this.props.navigation.dispatch({
|
||||
type: DrawerActions.DRAWER_OPENED,
|
||||
@@ -126,6 +144,7 @@ export default class DrawerView extends React.PureComponent {
|
||||
drawerWidth={this.state.drawerWidth}
|
||||
onDrawerOpen={this._handleDrawerOpen}
|
||||
onDrawerClose={this._handleDrawerClose}
|
||||
onDrawerStateChanged={this._handleDrawerStateChange}
|
||||
useNativeAnimations={this.props.navigationConfig.useNativeAnimations}
|
||||
renderNavigationView={this._renderNavigationView}
|
||||
drawerPosition={
|
||||
|
||||
Reference in New Issue
Block a user