MCPcopy
hub / github.com/ionic-team/ionic-framework / createMenuController

Function createMenuController

core/src/utils/menu-controller/index.ts:14–260  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

12import { menuRevealAnimation } from './animations/reveal';
13
14const createMenuController = (): MenuControllerI => {
15 const menuAnimations = new Map<string, AnimationBuilder>();
16 const menus: MenuI[] = [];
17
18 const open = async (menu?: string | null): Promise<boolean> => {
19 const menuEl = await get(menu, true);
20 if (menuEl) {
21 return menuEl.open();
22 }
23 return false;
24 };
25
26 const close = async (menu?: string | null): Promise<boolean> => {
27 const menuEl = await (menu !== undefined ? get(menu, true) : getOpen());
28 if (menuEl !== undefined) {
29 return menuEl.close();
30 }
31 return false;
32 };
33
34 const toggle = async (menu?: string | null): Promise<boolean> => {
35 const menuEl = await get(menu, true);
36 if (menuEl) {
37 return menuEl.toggle();
38 }
39 return false;
40 };
41
42 const enable = async (shouldEnable: boolean, menu?: string | null): Promise<HTMLIonMenuElement | undefined> => {
43 const menuEl = await get(menu);
44 if (menuEl) {
45 menuEl.disabled = !shouldEnable;
46 }
47 return menuEl;
48 };
49
50 const swipeGesture = async (shouldEnable: boolean, menu?: string | null): Promise<HTMLIonMenuElement | undefined> => {
51 const menuEl = await get(menu);
52 if (menuEl) {
53 menuEl.swipeGesture = shouldEnable;
54 }
55 return menuEl;
56 };
57
58 const isOpen = async (menu?: string | null): Promise<boolean> => {
59 if (menu != null) {
60 const menuEl = await get(menu);
61 // eslint-disable-next-line @typescript-eslint/prefer-optional-chain
62 return menuEl !== undefined && menuEl.isOpen();
63 } else {
64 const menuEl = await getOpen();
65 return menuEl !== undefined;
66 }
67 };
68
69 const isEnabled = async (menu?: string | null): Promise<boolean> => {
70 const menuEl = await get(menu);
71 if (menuEl) {

Callers 1

index.tsFile · 0.85

Calls 5

registerAnimationFunction · 0.85
_getOpenSyncFunction · 0.85
registerMethod · 0.80
addEventListenerMethod · 0.65
closeMethod · 0.65

Tested by

no test coverage detected