blowfish/assets/js/mobilemenu.js

33 lines
954 B
JavaScript
Raw Permalink Normal View History

var menuButton = document.getElementById("menu-button");
var menuCloseButton = document.getElementById("menu-close-button");
2024-09-03 18:10:11 -05:00
var menuWrapper = document.getElementById("menu-wrapper");
var menuOpen = false;
2024-09-03 18:10:11 -05:00
var openMenu = function (e) {
if (!menuOpen) {
menuOpen = true;
document.body.style.overflowY = "hidden";
menuButton.style.visibility = "hidden";
menuWrapper.style.visibility = "visible";
menuWrapper.style.opacity = "1";
2024-09-03 18:10:11 -05:00
window.onbeforeunload = function (event) {
closeMenu()
}
}
2024-09-03 18:10:11 -05:00
};
2024-09-03 18:10:11 -05:00
var closeMenu = function (e) {
if (menuOpen) {
menuOpen = false;
document.body.style.overflowY = "auto";
menuButton.style.visibility = "visible";
menuWrapper.style.visibility = "hidden";
menuWrapper.style.opacity = "0";
2024-09-03 18:10:11 -05:00
window.onbeforeunload = function (event) { }
e.stopPropagation();
}
2024-09-03 18:10:11 -05:00
}
menuButton.addEventListener("click", openMenu);
menuCloseButton.addEventListener("click", closeMenu);