From 758f060611e1d9e723861a878153bc46ba295c40 Mon Sep 17 00:00:00 2001 From: Steve Russo Date: Sun, 24 Apr 2022 20:46:34 -0400 Subject: [PATCH] close the nav via 'going back' in the browser --- layouts/partials/js-global.html | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/layouts/partials/js-global.html b/layouts/partials/js-global.html index 4179e63..f12cff6 100644 --- a/layouts/partials/js-global.html +++ b/layouts/partials/js-global.html @@ -2,6 +2,7 @@ function openNavDrawer() { navDrawerOverlay.classList.toggle('d-none') navDrawer.style.transform = 'translate(0)' + window.location.hash = '#nav' } function closeNavDrawer() { @@ -62,5 +63,17 @@ } setThemeTo(th) initToggle(th) + closeNavDrawer() })() + + if (window.location.hash == '#nav') { + history.replaceState("", document.title, window.location.pathname); + } + + window.addEventListener('hashchange', function(e) { + if (window.location.hash == '') { + closeNavDrawer() + history.replaceState("", document.title, window.location.pathname); + } + })