diff --git a/assets/js/mobilemenu.js b/assets/js/mobilemenu.js index b5d0dd041..a9d959057 100644 --- a/assets/js/mobilemenu.js +++ b/assets/js/mobilemenu.js @@ -1,27 +1,33 @@ var menuButton = document.getElementById("menu-button"); var menuCloseButton = document.getElementById("menu-close-button"); +var menuWrapper = document.getElementById("menu-wrapper"); var menuOpen = false; -menuButton.addEventListener("click", function () { +var openMenu = function (e) { if (!menuOpen) { menuOpen = true; - var menuWrapper = document.getElementById("menu-wrapper"); document.body.style.overflowY = "hidden"; menuButton.style.visibility = "hidden"; menuWrapper.style.visibility = "visible"; menuWrapper.style.opacity = "1"; + window.onbeforeunload = function (event) { + closeMenu() + } } -}); +}; -menuCloseButton.addEventListener("click", function (e) { +var closeMenu = function (e) { if (menuOpen) { menuOpen = false; - var menuWrapper = document.getElementById("menu-wrapper"); document.body.style.overflowY = "auto"; menuButton.style.visibility = "visible"; menuWrapper.style.visibility = "hidden"; menuWrapper.style.opacity = "0"; + window.onbeforeunload = function (event) { } e.stopPropagation(); } -}); \ No newline at end of file +} + +menuButton.addEventListener("click", openMenu); +menuCloseButton.addEventListener("click", closeMenu); \ No newline at end of file diff --git a/package.json b/package.json index 114314c55..a2f1304e7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hugo-blowfish-theme", - "version": "2.77.0", + "version": "2.77.1", "description": "Blowfish theme for Hugo.", "scripts": { "postinstall": "vendor-copy",