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