mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 12:29:55 +08:00
fix(menu): two menus can’t be animated at the same time
This commit is contained in:
@ -125,8 +125,8 @@ export class MenuController {
|
||||
* @return {Promise} returns a promise when the menu is fully opened
|
||||
*/
|
||||
open(menuId?: string): Promise<boolean> {
|
||||
let menu = this.get(menuId);
|
||||
if (menu) {
|
||||
const menu = this.get(menuId);
|
||||
if (menu && !this.isAnimating()) {
|
||||
let openedMenu = this.getOpen();
|
||||
if (openedMenu && menu !== openedMenu) {
|
||||
openedMenu.setOpen(false, false);
|
||||
@ -171,9 +171,9 @@ export class MenuController {
|
||||
* @return {Promise} returns a promise when the menu has been toggled
|
||||
*/
|
||||
toggle(menuId?: string): Promise<boolean> {
|
||||
let menu = this.get(menuId);
|
||||
if (menu) {
|
||||
let openedMenu = this.getOpen();
|
||||
const menu = this.get(menuId);
|
||||
if (menu && !this.isAnimating()) {
|
||||
var openedMenu = this.getOpen();
|
||||
if (openedMenu && menu !== openedMenu) {
|
||||
openedMenu.setOpen(false, false);
|
||||
}
|
||||
@ -191,7 +191,7 @@ export class MenuController {
|
||||
* @return {Menu} Returns the instance of the menu, which is useful for chaining.
|
||||
*/
|
||||
enable(shouldEnable: boolean, menuId?: string): Menu {
|
||||
let menu = this.get(menuId);
|
||||
const menu = this.get(menuId);
|
||||
if (menu) {
|
||||
return menu.enable(shouldEnable);
|
||||
}
|
||||
@ -204,7 +204,7 @@ export class MenuController {
|
||||
* @return {Menu} Returns the instance of the menu, which is useful for chaining.
|
||||
*/
|
||||
swipeEnable(shouldEnable: boolean, menuId?: string): Menu {
|
||||
let menu = this.get(menuId);
|
||||
const menu = this.get(menuId);
|
||||
if (menu) {
|
||||
return menu.swipeEnable(shouldEnable);
|
||||
}
|
||||
@ -229,7 +229,7 @@ export class MenuController {
|
||||
* @return {boolean} Returns true if the menu is currently enabled, otherwise false.
|
||||
*/
|
||||
isEnabled(menuId?: string): boolean {
|
||||
let menu = this.get(menuId);
|
||||
const menu = this.get(menuId);
|
||||
return menu && menu.enabled || false;
|
||||
}
|
||||
|
||||
@ -278,7 +278,6 @@ export class MenuController {
|
||||
return this._menus.find(m => m.isOpen);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return {Array<Menu>} Returns an array of all menu instances.
|
||||
*/
|
||||
@ -286,6 +285,14 @@ export class MenuController {
|
||||
return this._menus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @return {boolean} if any menu is currently animating
|
||||
*/
|
||||
isAnimating(): boolean {
|
||||
return this._menus.some(menu => menu.isAnimating());
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
|
@ -412,7 +412,7 @@ export class Menu {
|
||||
setOpen(shouldOpen: boolean, animated: boolean = true): Promise<boolean> {
|
||||
// _isPrevented is used to prevent unwanted opening/closing after swiping open/close
|
||||
// or swiping open the menu while pressing down on the MenuToggle button
|
||||
if ((shouldOpen && this.isOpen) || !this._isEnabled || this._isAnimating) {
|
||||
if ((shouldOpen === this.isOpen) || !this._isEnabled || this._isAnimating) {
|
||||
return Promise.resolve(this.isOpen);
|
||||
}
|
||||
|
||||
@ -436,6 +436,13 @@ export class Menu {
|
||||
this._app.isEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
isAnimating(): boolean {
|
||||
return this._isAnimating;
|
||||
}
|
||||
|
||||
_swipeBeforeStart() {
|
||||
if (!this.canSwipe()) {
|
||||
assert(false, 'canSwipe() has to be true');
|
||||
|
Reference in New Issue
Block a user