2024-06-20 07:51:56 +02:00
|
|
|
// @license magnet:?xt=urn:btih:90dc5c0be029de84e523b9b3922520e79e0e6f08&dn=cc0.txt CC0-1.0
|
2024-06-24 19:24:56 +02:00
|
|
|
// burger.js
|
|
|
|
|
2024-06-19 08:58:57 +02:00
|
|
|
function toggleMenu() {
|
2024-06-24 19:24:56 +02:00
|
|
|
const menu = document.querySelector(".menu");
|
2024-06-25 10:14:04 +02:00
|
|
|
|
|
|
|
// Toggle the 'active' class to show/hide the menu
|
2024-06-24 19:24:56 +02:00
|
|
|
menu.classList.toggle("active");
|
|
|
|
|
2024-06-25 10:14:04 +02:00
|
|
|
// Apply animations based on the menu's visibility
|
2024-06-24 19:24:56 +02:00
|
|
|
if (menu.classList.contains("active")) {
|
2024-06-25 10:14:04 +02:00
|
|
|
menu.style.animation = "slideIn 0.3s forwards";
|
2024-06-24 19:24:56 +02:00
|
|
|
document.addEventListener("click", closeMenu);
|
|
|
|
} else {
|
2024-06-25 10:14:04 +02:00
|
|
|
menu.style.animation = "slideOut 0.3s forwards";
|
|
|
|
// Remove the event listener to close the menu
|
2024-06-24 19:24:56 +02:00
|
|
|
document.removeEventListener("click", closeMenu);
|
2024-06-25 10:14:04 +02:00
|
|
|
// Reset animation after it's completed
|
|
|
|
menu.addEventListener("animationend", () => {
|
|
|
|
menu.style.animation = "";
|
|
|
|
}, { once: true });
|
2024-06-24 19:24:56 +02:00
|
|
|
}
|
2024-06-20 07:51:56 +02:00
|
|
|
}
|
2024-06-24 19:24:56 +02:00
|
|
|
|
|
|
|
function closeMenu(event) {
|
|
|
|
const menu = document.querySelector(".menu");
|
2024-06-25 10:14:04 +02:00
|
|
|
// Check if the click is outside the menu and not on the burger icon
|
2024-06-24 19:24:56 +02:00
|
|
|
if (!menu.contains(event.target) && !event.target.classList.contains("burger-menu")) {
|
2024-06-25 10:14:04 +02:00
|
|
|
menu.style.animation = "slideOut 0.3s forwards";
|
|
|
|
// Remove the event listener to close the menu
|
2024-06-24 19:24:56 +02:00
|
|
|
document.removeEventListener("click", closeMenu);
|
2024-06-25 10:14:04 +02:00
|
|
|
// Reset animation after it's completed
|
|
|
|
menu.addEventListener("animationend", () => {
|
|
|
|
menu.classList.remove("active");
|
|
|
|
menu.style.animation = "";
|
|
|
|
}, { once: true });
|
2024-06-24 19:24:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// @license-end
|