Skip to content

Commit

Permalink
close menu on click around, code style #59
Browse files Browse the repository at this point in the history
  • Loading branch information
openmindculture committed Oct 11, 2023
1 parent 1638b53 commit 5658e4d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
10 changes: 10 additions & 0 deletions src/js/inc/enhanceNavigationMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ export function kleiderordnung_enhanceNavigationMenu(config) {
window.kleiderordnung.state.menu.classList.remove(config.menuOpenedClassName);
window.kleiderordnung.state.menuOpenButton.classList.remove(config.menuOpenedClassName);
});
if (typeof(menuCloseButton.closest)==='function') {
var menuWrapper = menuCloseButton.closest(config.menuWrapperSelector);
if (menuWrapper) {
menuWrapper.addEventListener('click', function (event) {
if (event.target instanceof HTMLAnchorElement) { return; }
window.kleiderordnung.state.menu.classList.remove(config.menuOpenedClassName);
window.kleiderordnung.state.menuOpenButton.classList.remove(config.menuOpenedClassName);
});
}
}
}

var navLinks = document.querySelectorAll(config.menuLinksSelector);
Expand Down
7 changes: 4 additions & 3 deletions src/js/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,10 @@ window.kleiderordnung = {
menuId: 'primary-menu',
menuCloseButtonClassName: 'navigation__toggle--close',
menuOpenButtonClassName: 'navigation__toggle--open',
menuOpenedClassName: 'navigation__menu-opened', // .target for progressive enhancement of :target
menuLinksSelector: '#primary-menu a[href]', // links inside the menu
noGlobalThisClassName: 'no-globalthis', // set if special intro animation fallback necessary
menuOpenedClassName: 'navigation__menu-opened', // .target for progressive enhancement of :target
menuLinksSelector: '#primary-menu a[href]', // links inside the menu
menuWrapperSelector: '.navigation__list-wrapper',// div around the menu items
noGlobalThisClassName: 'no-globalthis', // set if special intro animation fallback necessary
/** @object IntersectionObserver options */
observerOptions: {
root: null,
Expand Down

0 comments on commit 5658e4d

Please sign in to comment.