This commit is contained in:
mark
2023-04-10 14:16:45 +02:00
parent 31e4161258
commit 6be2bb28f8
2 changed files with 11 additions and 3 deletions

View File

@@ -1,5 +1,6 @@
const navbar = document.querySelector('.navbar')
const toggler = document.getElementById('main-nav-toggler')
const modeSelectors = document.querySelectorAll('.switch-mode-collapsed')
// set the navbar background color to opaque when scrolling past a breakpoint
window.onscroll = () => {
@@ -14,3 +15,10 @@ window.onscroll = () => {
toggler.onclick = () => {
navbar.classList.toggle('navbar-expanded')
}
// invoke the navbar toggler for each mode switcher to collapse the main menu afterwards
for (let i = 0; i < modeSelectors.length; ++i) {
modeSelectors[i].onclick = () => {
toggler.click()
}
}