Use data attribute instead of class for mobile navopen.
This commit is contained in:
parent
76ab47f22d
commit
847e2b10ba
1 changed files with 9 additions and 9 deletions
|
|
@ -12,14 +12,14 @@
|
|||
const toggle = document.querySelector('.mobile-nav__toggle');
|
||||
|
||||
function navopen() {
|
||||
nav.classList.add('js-nav-open');
|
||||
nav.dataset.navopen='true';
|
||||
sheet.setAttribute('aria-hidden', 'false');
|
||||
toggle.setAttribute('aria-expanded', 'true');
|
||||
document.body.addEventListener('keydown', closeonesc);
|
||||
}
|
||||
|
||||
function navclose() {
|
||||
nav.classList.remove('js-nav-open');
|
||||
delete nav.dataset.navopen;
|
||||
sheet.setAttribute('aria-hidden', 'true');
|
||||
toggle.setAttribute('aria-expanded', 'false');
|
||||
document.body.removeEventListener('keydown', closeonesc);
|
||||
|
|
@ -37,7 +37,7 @@
|
|||
toggles.forEach(function (toggle) {
|
||||
toggle.addEventListener('click', function (e) {
|
||||
e.preventDefault();
|
||||
if (nav.classList.contains('js-nav-open')) {
|
||||
if (nav.dataset.navopen) {
|
||||
navclose();
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
Loading…
Reference in a new issue