fix(menu-controller): expose registerAnimation

fixes #15701
This commit is contained in:
Manu Mtz.-Almeida
2018-09-25 16:53:16 +02:00
parent c048f9fda2
commit 29d00da2b4
3 changed files with 21 additions and 24 deletions

View File

@ -1,8 +1,8 @@
/* tslint:disable */
/**
* This is an autogenerated file created by the Stencil compiler.
* It contains typing information for all components that exist in this project.
*/
/* tslint:disable */
import '@stencil/core';
@ -2481,6 +2481,7 @@ export namespace Components {
* Open the menu.
*/
'open': (menuId?: string | null | undefined) => Promise<boolean>;
'registerAnimation': (name: string, animation: AnimationBuilder) => void;
/**
* Used to enable or disable the ability to swipe open the menu.
*/

View File

@ -186,6 +186,11 @@ export class MenuController implements MenuControllerI {
return Promise.resolve(this.isAnimatingSync());
}
@Method()
registerAnimation(name: string, animation: AnimationBuilder) {
this.menuAnimations.set(name, animation);
}
@Method()
_register(menu: MenuI) {
if (this.menus.indexOf(menu) < 0) {
@ -252,10 +257,6 @@ export class MenuController implements MenuControllerI {
return this.menus.some(menu => menu.isAnimating);
}
private registerAnimation(name: string, animation: AnimationBuilder) {
this.menuAnimations.set(name, animation);
}
private find(predicate: (menu: MenuI) => boolean): HTMLIonMenuElement | undefined {
const instance = this.menus.find(predicate);
if (instance !== undefined) {

View File

@ -8,25 +8,20 @@ The MenuController makes it easy to control a Menu. Its methods can be used to d
## Methods
| Method | Description |
| ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `_createAnimation` | |
| `_getInstance` | |
| `_register` | |
| `_setActiveMenu` | |
| `_setOpen` | |
| `_unregister` | |
| `close` | Close the menu. If no menu is specified, then it will close any menu that is open. If a menu is specified, it will close that menu. |
| `enable` | Used to enable or disable a menu. For example, there could be multiple left menus, but only one of them should be able to be opened at the same time. If there are multiple menus on the same side, then enabling one menu will also automatically disable all the others that are on the same side. |
| `get` | Used to get a menu instance. If a menu is not provided then it will return the first menu found. If the specified menu is `left` or `right`, then it will return the enabled menu on that side. Otherwise, it will try to find the menu using the menu's `id` property. If a menu is not found then it will return `null`. |
| `getMenus` | Returns an array of all menu instances. |
| `getOpen` | Returns the instance of the menu already opened, otherwise `null`. |
| `isAnimating` | Returns true if any menu is currently animating. |
| `isEnabled` | Returns true if the specified menu is enabled. |
| `isOpen` | Returns true if the specified menu is open. If the menu is not specified, it will return true if any menu is currently open. |
| `open` | Open the menu. |
| `swipeGesture` | Used to enable or disable the ability to swipe open the menu. |
| `toggle` | Toggle the menu. If it's closed, it will open, and if opened, it will close. |
| Method | Description |
| ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `close` | Close the menu. If no menu is specified, then it will close any menu that is open. If a menu is specified, it will close that menu. |
| `enable` | Used to enable or disable a menu. For example, there could be multiple left menus, but only one of them should be able to be opened at the same time. If there are multiple menus on the same side, then enabling one menu will also automatically disable all the others that are on the same side. |
| `get` | Used to get a menu instance. If a menu is not provided then it will return the first menu found. If the specified menu is `left` or `right`, then it will return the enabled menu on that side. Otherwise, it will try to find the menu using the menu's `id` property. If a menu is not found then it will return `null`. |
| `getMenus` | Returns an array of all menu instances. |
| `getOpen` | Returns the instance of the menu already opened, otherwise `null`. |
| `isAnimating` | Returns true if any menu is currently animating. |
| `isEnabled` | Returns true if the specified menu is enabled. |
| `isOpen` | Returns true if the specified menu is open. If the menu is not specified, it will return true if any menu is currently open. |
| `open` | Open the menu. |
| `registerAnimation` | |
| `swipeGesture` | Used to enable or disable the ability to swipe open the menu. |
| `toggle` | Toggle the menu. If it's closed, it will open, and if opened, it will close. |
----------------------------------------------