Repo for my website
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
634 B

4 years ago
// Mobile menu
const menuTrigger = document.querySelector(".menu-trigger");
const menu = document.querySelector(".menu");
const mobileQuery = getComputedStyle(document.body).getPropertyValue(
"--phoneWidth"
4 years ago
);
const isMobile = () => window.matchMedia(mobileQuery).matches;
const isMobileMenu = () => {
menuTrigger && menuTrigger.classList.toggle("hidden", !isMobile());
menu && menu.classList.toggle("hidden", isMobile());
4 years ago
};
isMobileMenu();
menuTrigger &&
menuTrigger.addEventListener(
"click",
() => menu && menu.classList.toggle("hidden")
);
4 years ago
window.addEventListener("resize", isMobileMenu);