close the nav via 'going back' in the browser #47

Merged
jeff merged 2 commits from back-button-close-nav into master 2022-04-25 16:38:54 +00:00
Showing only changes of commit 758f060611 - Show all commits

View File

@ -2,6 +2,7 @@
function openNavDrawer() { function openNavDrawer() {
navDrawerOverlay.classList.toggle('d-none') navDrawerOverlay.classList.toggle('d-none')
navDrawer.style.transform = 'translate(0)' navDrawer.style.transform = 'translate(0)'
window.location.hash = '#nav'
} }
function closeNavDrawer() { function closeNavDrawer() {
@ -62,5 +63,17 @@
} }
setThemeTo(th) setThemeTo(th)
initToggle(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> </script>