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

23 lines
605 B
JavaScript
Raw Normal View History

2021-02-09 01:03:38 +00:00
(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);
}
)
})()