diff --git a/src/components/menu/menu-controller.ts b/src/components/menu/menu-controller.ts
index 783a9f1039..d6b7114709 100644
--- a/src/components/menu/menu-controller.ts
+++ b/src/components/menu/menu-controller.ts
@@ -156,6 +156,12 @@ export class MenuController {
return Promise.resolve(false);
}
+ tempDisable(temporarilyDisable: boolean) {
+ this._menus.forEach(menu => {
+ menu.tempDisable(temporarilyDisable);
+ });
+ }
+
/**
* Toggle the menu. If it's closed, it will open, and if opened, it
* will close.
diff --git a/src/components/menu/menu.ts b/src/components/menu/menu.ts
index 02868d161e..5c31243366 100644
--- a/src/components/menu/menu.ts
+++ b/src/components/menu/menu.ts
@@ -198,6 +198,7 @@ export class Menu extends Ion {
private _isSwipeEnabled: boolean = true;
private _isPers: boolean = false;
private _init: boolean = false;
+ private _prevEnabled: boolean;
/**
* @private
@@ -419,10 +420,10 @@ export class Menu extends Ion {
*/
swipeStart() {
// user started swiping the menu open/close
- if (this._isPrevented() || !this._isEnabled || !this._isSwipeEnabled) return;
-
- this._before();
- this._getType().setProgressStart(this.isOpen);
+ if (this._isEnabled && this._isSwipeEnabled && !this._isPrevented()) {
+ this._before();
+ this._getType().setProgressStart(this.isOpen);
+ }
}
/**
@@ -451,9 +452,6 @@ export class Menu extends Ion {
}
}
- /**
- * @private
- */
private _before() {
// this places the menu into the correct location before it animates in
// this css class doesn't actually kick off any animations
@@ -466,9 +464,6 @@ export class Menu extends Ion {
}
}
- /**
- * @private
- */
private _after(isOpen: boolean) {
// keep opening/closing the menu disabled for a touch more yet
// only add listeners/css if it's enabled and isOpen
@@ -495,15 +490,24 @@ export class Menu extends Ion {
/**
* @private
*/
+ tempDisable(temporarilyDisable: boolean) {
+ if (temporarilyDisable) {
+ this._prevEnabled = this._isEnabled;
+ this._getType().setProgessStep(0);
+ this.enable(false);
+
+ } else {
+ this.enable(this._prevEnabled);
+ this._after(false);
+ }
+ }
+
private _prevent() {
// used to prevent unwanted opening/closing after swiping open/close
// or swiping open the menu while pressing down on the MenuToggle
this._preventTime = Date.now() + 20;
}
- /**
- * @private
- */
private _isPrevented() {
return this._preventTime > Date.now();
}
diff --git a/src/components/menu/test/basic/index.ts b/src/components/menu/test/basic/index.ts
index 50e14b4d3c..3e5830c310 100644
--- a/src/components/menu/test/basic/index.ts
+++ b/src/components/menu/test/basic/index.ts
@@ -1,4 +1,5 @@
-import {App, IonicApp, MenuController, Page, NavController, Alert} from '../../../../../src';
+import {ViewChild} from '@angular/core';
+import {App, IonicApp, MenuController, Page, NavController, Alert, Nav} from '../../../../../src';
@Page({
@@ -16,6 +17,10 @@ class Page1 {
});
this.nav.present(alert);
}
+
+ goToPage2() {
+ this.nav.push(Page2);
+ }
}
@@ -40,6 +45,7 @@ class E2EApp {
rootPage;
changeDetectionCount: number = 0;
pages: Array<{title: string, component: any}>;
+ @ViewChild(Nav) nav: Nav;
constructor(private app: IonicApp, private menu: MenuController) {
this.rootPage = Page1;
@@ -54,8 +60,7 @@ class E2EApp {
openPage(page) {
// Reset the content nav to have just this page
// we wouldn't want the back button to show in this scenario
- let nav = this.app.getComponent('nav');
- nav.setRoot(page.component).then(() => {
+ this.nav.setRoot(page.component).then(() => {
// wait for the root page to be completely loaded
// then close the menu
this.menu.close();
diff --git a/src/components/menu/test/basic/main.html b/src/components/menu/test/basic/main.html
index b4f7b0a711..d607c74b63 100644
--- a/src/components/menu/test/basic/main.html
+++ b/src/components/menu/test/basic/main.html
@@ -138,6 +138,6 @@
-
+ +
+