wp-73k/assets/js/modules/menu.js
2019-05-23 10:30:31 -06:00

30 lines
No EOL
486 B
JavaScript

export default () => {
const toggles = document.querySelectorAll('.toggle')
const menu = document.querySelector('.nav-mobile')
if ( ! toggles || ! menu ) {
return;
}
let active = false
toggles.forEach(toggle => {
toggle.addEventListener( 'click', () => {
if ( active ) {
open();
} else {
close();
}
})
})
function open() {
menu.classList.remove('active')
active = false
}
function close() {
menu.classList.add('active')
active = true
}
}