From dc53c8e9f633a79a8b6ae72f09a36a5df6028eff Mon Sep 17 00:00:00 2001 From: "Manu Mtz.-Almeida" Date: Fri, 3 Mar 2017 20:26:37 +0100 Subject: [PATCH] fix(menu): all menus can be disabled --- src/components/menu/menu.ts | 19 ++++++++++++------- .../menu/test/multiple/app.module.ts | 7 +++---- src/components/menu/test/multiple/main.html | 4 ++-- src/components/slides/slides.ts | 8 +++++++- 4 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/components/menu/menu.ts b/src/components/menu/menu.ts index 6728e1d383..a8c7a9383d 100644 --- a/src/components/menu/menu.ts +++ b/src/components/menu/menu.ts @@ -197,7 +197,7 @@ export class Menu implements RootNode { private _cntEle: HTMLElement; private _gesture: MenuContentGesture; private _type: MenuType; - private _isEnabled: boolean = false; + private _isEnabled: boolean; private _isSwipeEnabled: boolean = true; private _isAnimating: boolean = false; private _isPersistent: boolean = false; @@ -357,16 +357,18 @@ export class Menu implements RootNode { this._cntEle.classList.add('menu-content'); this._cntEle.classList.add('menu-content-' + this.type); - // check if more than one menu is on the same side - let shouldEnable = !this._menuCtrl.getMenus().some(m => { - return m.side === this.side && m.enabled; - }); - + let isEnabled = this._isEnabled; + if (isEnabled === true || typeof isEnabled === 'undefined') { + // check if more than one menu is on the same side + isEnabled = !this._menuCtrl.getMenus().some(m => { + return m.side === this.side && m.enabled; + }); + } // register this menu with the app's menu controller this._menuCtrl._register(this); // mask it as enabled / disabled - this.enable(shouldEnable); + this.enable(isEnabled); } /** @@ -580,6 +582,7 @@ export class Menu implements RootNode { // Close menu inmediately if (!canOpen && this.isOpen) { + assert(this._init, 'menu must be initialized'); // close if this menu is open, and should not be enabled this._forceClosing(); } @@ -591,6 +594,7 @@ export class Menu implements RootNode { if (!this._init) { return; } + const gesture = this._gesture; // only listen/unlisten if the menu has initialized if (canOpen && this._isSwipeEnabled && !gesture.isListening) { @@ -603,6 +607,7 @@ export class Menu implements RootNode { console.debug('menu, gesture unlisten', this.side); gesture.unlisten(); } + if (this.isOpen || (this._isPane && this._isEnabled)) { this.resize(); } diff --git a/src/components/menu/test/multiple/app.module.ts b/src/components/menu/test/multiple/app.module.ts index 1a8e3874e4..f1d042980d 100644 --- a/src/components/menu/test/multiple/app.module.ts +++ b/src/components/menu/test/multiple/app.module.ts @@ -6,11 +6,10 @@ import { IonicApp, IonicModule, MenuController } from '../../../../../ionic-angu templateUrl: 'page1.html' }) export class Page1 { - activeMenu: string; + activeMenu: string = 'none'; + + constructor(private menu: MenuController) { } - constructor(private menu: MenuController) { - this.menu1Active(); - } menu1Active() { this.activeMenu = 'menu1'; this.menu.enable(true, 'menu1'); diff --git a/src/components/menu/test/multiple/main.html b/src/components/menu/test/multiple/main.html index ace2c5772d..47c8783aeb 100644 --- a/src/components/menu/test/multiple/main.html +++ b/src/components/menu/test/multiple/main.html @@ -1,4 +1,4 @@ - + @@ -17,7 +17,7 @@ - + diff --git a/src/components/slides/slides.ts b/src/components/slides/slides.ts index 2c1d318034..86a9e7aac8 100644 --- a/src/components/slides/slides.ts +++ b/src/components/slides/slides.ts @@ -107,7 +107,7 @@ import { ViewController } from '../../navigation/view-controller'; * ```ts * import { ViewChild } from '@angular/core'; * import { Slides } from 'ionic-angular'; - + * class MyPage { * @ViewChild(Slides) slides: Slides; * @@ -971,6 +971,12 @@ export class Slides extends Ion { } } + resize() { + if (this._init) { + + } + } + /** * Transition to the specified slide. *