Skip to content

Instantly share code, notes, and snippets.

@jasdeepkhalsa
Created September 17, 2015 09:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasdeepkhalsa/5cd5b4e771e8c1431b08 to your computer and use it in GitHub Desktop.
Save jasdeepkhalsa/5cd5b4e771e8c1431b08 to your computer and use it in GitHub Desktop.
Toggle and initialise a menu's state
var menuVisible = false;
// Can be used with the components manager. If so, uncomment out the lines below to add & remove event listeners
function initMenu() {
if (document.querySelector(menu)) {
if (menuVisible) {
// app.components.addListeners();
document.querySelector(menu).style.display = block;
} else {
// app.components.removeListeners();
document.querySelector(menu).style.display = none;
}
}
}
function toggleMenu() {
if (document.querySelector(menu)) {
if (menuVisible) {
// app.components.removeListeners();
document.querySelector(menu).style.display = none;
menuVisible = false;
} else {
// app.components.addListeners();
document.querySelector(menu).style.display = block;
menuVisible = true;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment