Added navigation menu animation

This commit is contained in:
Kristofers Solo
2023-01-19 18:15:44 +02:00
parent 1560d9fc71
commit eaf0a7d8ab
7 changed files with 147 additions and 243 deletions

View File

@@ -1,13 +1,15 @@
const PRIMARY_NAV = document.querySelector(".primary-navigation")
const EMAIL = document.querySelector(".mobile-nav-toggle")
const MENU_BUTTON = document.querySelector(".mobile-nav-toggle")
EMAIL.addEventListener("click", () => {
MENU_BUTTON.addEventListener("click", () => {
const VISIBILITY = PRIMARY_NAV.getAttribute("data-visible") === "false"
if (VISIBILITY) {
PRIMARY_NAV.setAttribute("data-visible", true)
EMAIL.setAttribute("aria-expanded", true)
MENU_BUTTON.setAttribute("aria-expanded", true)
MENU_BUTTON.classList.add("open")
} else {
PRIMARY_NAV.setAttribute("data-visible", false)
EMAIL.setAttribute("aria-expanded", false)
MENU_BUTTON.setAttribute("aria-expanded", false)
MENU_BUTTON.classList.remove("open")
}
})