Link to anchor: how to close Mmenu light?

69 views Asked by At

Mmenu light: Is there a way to close the menu when clicking on a link to internal anchors?

With mmenu.js there is the possibility. Is there any chance of getting the same thing with mmenu-light.js?

1

There are 1 answers

0
shawn On

You should listen for a click event on that element and write drawer.close();. And if you want to get back one step, listen for a click event and write inside that event:

// Create an instance of the mmenu light plugin
const menu = new MmenuLight(document.querySelector("#menu"));

// Get the navigator object
const navigator = menu.navigation();
const panel = document.querySelector(`ul[that ul is closest to your fallback btn]`);
navigator.openPanel(panel);