close the nav via 'going back' in the browser

This commit is contained in:
Steve Russo 2022-04-24 20:46:34 -04:00
parent 795005fcec
commit 758f060611
1 changed files with 13 additions and 0 deletions

View File

@ -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);
}
})
</script>