Created
November 6, 2018 09:24
-
-
Save uryu-myao/3752273e2fb79db3d7292b4466822195 to your computer and use it in GitHub Desktop.
OVERLAY MENU
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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