tw-runner
Version:
Run and manage Tower Website projects with this utility.
28 lines (25 loc) • 1.18 kB
JavaScript
document.addEventListener("DOMContentLoaded", function () {
const menuButton = document.getElementById('menu-button');
const mobileMenu = document.getElementById('mobile-menu');
const menuIconParent = menuButton.querySelector(".menu-icon-parent");
const menuIconChild = menuButton.querySelector(".menu-icon-child");
const openMenuIcon = {
child: { path: "M15 4H1V2h14zm0 5H1V7h14zM1 14h14v-2H1z" },
parent: { view: "0 0 16 16" }
};
const closeMenuIcon = {
child: { path: "M24 2.4L21.6 0L12 9.6L2.4 0L0 2.4L9.6 12L0 21.6L2.4 24l9.6-9.6l9.6 9.6l2.4-2.4l-9.6-9.6z" },
parent: { view: "0 0 24 24" }
};
menuButton.addEventListener('click', function () {
mobileMenu.classList.toggle('engaged');
document.body.classList.toggle("no-scroll", mobileMenu.classList.contains("engaged"));
if (mobileMenu.classList.contains("engaged")) {
menuIconChild.setAttribute("d", closeMenuIcon.child.path);
menuIconParent.setAttribute("viewBox", closeMenuIcon.parent.view);
} else {
menuIconChild.setAttribute("d", openMenuIcon.child.path);
menuIconParent.setAttribute("viewBox", openMenuIcon.parent.view);
}
});
});