This repository has been archived on 2023-11-13. You can view files and clone it, but cannot push or open issues or pull requests.
imagini/docs/schema/scripts/toggle-navigation.js
2021-02-08 20:03:38 -05:00

23 lines
605 B
JavaScript

(function () {
var ACTIVE_CLASS = 'is-active';
var navigation = document.querySelector('nav');
var toggles = document.querySelectorAll('.js-toggle-navigation');
function toggleNavigation() {
navigation.classList.contains(ACTIVE_CLASS) ?
navigation.classList.remove(ACTIVE_CLASS) :
navigation.classList.add(ACTIVE_CLASS);
}
Array.prototype.forEach.call(
toggles,
/**
* @param {HTMLElement} toggle
*/
function (toggle) {
toggle.addEventListener('click', toggleNavigation);
}
)
})()