Skip to content

Instantly share code, notes, and snippets.

@uryu-myao
Created November 6, 2018 09:24
Show Gist options
  • Save uryu-myao/3752273e2fb79db3d7292b4466822195 to your computer and use it in GitHub Desktop.
Save uryu-myao/3752273e2fb79db3d7292b4466822195 to your computer and use it in GitHub Desktop.
OVERLAY MENU
const MENU = (function () {
let menu = document.querySelector('.menu'),
overlay = document.querySelector('.overlay'),
navItem = document.querySelectorAll('.overlay_item')
let active = false
let toggleMenu = function () {
if (!active) {
overlay.classList.add('overlay_active');
menu.classList.add('menu_active');
for (var i = 0; i < navItem.length; i++) {
navItem[i].classList.add('overlay_item_active')
}
active = true
} else {
overlay.classList.remove('overlay_active');
menu.classList.remove('menu_active');
for (var i = 0; i < navItem.length; i++) {
navItem[i].classList.remove('overlay_item_active')
}
active = false
}
}
let bindActions = function () {
menu.addEventListener('click', toggleMenu, false)
}
let init = function () {
bindActions()
}
return { init: init }
}());
MENU.init();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment