13 行
336 B
JavaScript
13 行
336 B
JavaScript
// Closes the open menu when the window becomes wide enough to show the horizontal menu.
|
|
const menu = document.getElementById("site-menu");
|
|
const wide = window.matchMedia("(min-width: 48rem)");
|
|
|
|
function closeMenu() {
|
|
if (wide.matches && menu?.open) {
|
|
menu.close();
|
|
}
|
|
}
|
|
|
|
wide.addEventListener("change", closeMenu);
|
|
closeMenu();
|