From cdab348a878baf31e6d124b39ed2d0e0f90d24df Mon Sep 17 00:00:00 2001 From: zombieFox Date: Sat, 28 Aug 2021 00:28:54 +0100 Subject: [PATCH] open menu with name --- src/component/menu/index.js | 8 +++++++- src/component/menuNav/index.js | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/component/menu/index.js b/src/component/menu/index.js index 2508411d..9d111d83 100644 --- a/src/component/menu/index.js +++ b/src/component/menu/index.js @@ -35,12 +35,18 @@ menu.element = { frame: null }; -menu.open = () => { +menu.open = (name) => { menu.element.frame = new MenuFrame({ navData: menu.navData }); + if (name) { + + menu.element.frame.menuNav.state.toggle(name); + + }; + menu.element.frame.open(); }; diff --git a/src/component/menuNav/index.js b/src/component/menuNav/index.js index 7c210e3c..07de0602 100644 --- a/src/component/menuNav/index.js +++ b/src/component/menuNav/index.js @@ -34,7 +34,7 @@ export const MenuNav = function({ item.active = false; - if (item.name === name) { + if (item.name === name || item.name.toLowerCase() === name) { item.active = true; }; @@ -67,11 +67,13 @@ export const MenuNav = function({ }; this.update = () => { + navData.forEach((item, i) => { if (this.state.current[this.makeId(item.name)]) { this.element.item[i].menuNavItem.classList.add('active'); + this.element.item[i].topLevel.classList.add('active'); if (item.sub) { @@ -85,7 +87,9 @@ export const MenuNav = function({ }; } else { + this.element.item[i].menuNavItem.classList.remove('active'); + this.element.item[i].topLevel.classList.remove('active'); if (item.sub) { @@ -101,6 +105,7 @@ export const MenuNav = function({ }; }); + }; this.nav = () => {