24 lines
606 B
JavaScript
24 lines
606 B
JavaScript
|
|
let handleClick;
|
||
|
|
|
||
|
|
function expandNav(nodes) {
|
||
|
|
nodes.expandedNav.classList.add("open");
|
||
|
|
|
||
|
|
nodes.burgerBtn.setAttribute("aria-expanded", true);
|
||
|
|
nodes.closeNavBtn.setAttribute("aria-expanded", true);
|
||
|
|
|
||
|
|
handleClick = () => closeNav(nodes);
|
||
|
|
nodes.main.addEventListener("click", handleClick);
|
||
|
|
}
|
||
|
|
|
||
|
|
function closeNav(nodes) {
|
||
|
|
console.log("close nav");
|
||
|
|
nodes.expandedNav.classList.remove("open");
|
||
|
|
|
||
|
|
nodes.burgerBtn.setAttribute("aria-expanded", false);
|
||
|
|
nodes.closeNavBtn.setAttribute("aria-expanded", false);
|
||
|
|
|
||
|
|
nodes.main.removeEventListener("click", handleClick);
|
||
|
|
}
|
||
|
|
|
||
|
|
export { expandNav, closeNav };
|