mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-04-28 20:35:19 +08:00
Merge pull request #1 from solomonhawk/sfh/fix-drawer-quick-navigate
Fix a bug in DrawerView
This commit is contained in:
@@ -24,10 +24,10 @@ export default class DrawerView extends React.PureComponent {
|
|||||||
const { isDrawerOpen } = this.props.navigation.state;
|
const { isDrawerOpen } = this.props.navigation.state;
|
||||||
const wasDrawerOpen = prevProps.navigation.state.isDrawerOpen;
|
const wasDrawerOpen = prevProps.navigation.state.isDrawerOpen;
|
||||||
|
|
||||||
if (isDrawerOpen && !wasDrawerOpen && this._drawerState === 'closed') {
|
if (this._shouldOpen(isDrawerOpen, wasDrawerOpen)) {
|
||||||
this._drawerState = 'opening';
|
this._drawerState = 'opening';
|
||||||
this._drawer.openDrawer();
|
this._drawer.openDrawer();
|
||||||
} else if (wasDrawerOpen && !isDrawerOpen && this._drawerState === 'open') {
|
} else if (this._shouldClose(isDrawerOpen, wasDrawerOpen)) {
|
||||||
this._drawerState = 'closing';
|
this._drawerState = 'closing';
|
||||||
this._drawer.closeDrawer();
|
this._drawer.closeDrawer();
|
||||||
}
|
}
|
||||||
@@ -39,6 +39,22 @@ export default class DrawerView extends React.PureComponent {
|
|||||||
|
|
||||||
_drawerState = 'closed';
|
_drawerState = 'closed';
|
||||||
|
|
||||||
|
_shouldOpen = (isDrawerOpen, wasDrawerOpen) => {
|
||||||
|
return (
|
||||||
|
isDrawerOpen &&
|
||||||
|
!wasDrawerOpen &&
|
||||||
|
(this._drawerState === 'closed' || this._drawerState === 'closing')
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
_shouldClose = (isDrawerOpen, wasDrawerOpen) => {
|
||||||
|
return (
|
||||||
|
wasDrawerOpen &&
|
||||||
|
!isDrawerOpen &&
|
||||||
|
(this._drawerState === 'open' || this._drawerState === 'opening')
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
_handleDrawerOpen = () => {
|
_handleDrawerOpen = () => {
|
||||||
const { navigation } = this.props;
|
const { navigation } = this.props;
|
||||||
const { isDrawerOpen } = navigation.state;
|
const { isDrawerOpen } = navigation.state;
|
||||||
|
|||||||
Reference in New Issue
Block a user