mirror of
https://github.com/robonen/wine-beer-concept.git
synced 2026-03-20 02:24:30 +00:00
Init commit
This commit is contained in:
26
js/index.js
Normal file
26
js/index.js
Normal file
@@ -0,0 +1,26 @@
|
||||
const d = document;
|
||||
|
||||
const body = d.querySelector('body');
|
||||
const btn = d.querySelector('button.hamburger_btn');
|
||||
const menu = d.querySelector('header > .mobile_menu');
|
||||
|
||||
|
||||
btn.addEventListener('click', e => {
|
||||
const isOpen = btn.classList.contains('opened');
|
||||
|
||||
if (!isOpen) {
|
||||
btn.classList.add('opened');
|
||||
body.style.overflow = 'hidden';
|
||||
menu.style.visibility = 'visible';
|
||||
menu.classList.add('mobile_menu_opened');
|
||||
} else {
|
||||
menu.classList.remove('mobile_menu_opened');
|
||||
body.style.overflow = 'visible';
|
||||
btn.classList.remove('opened');
|
||||
setTimeout(() => {
|
||||
menu.style.visibility = 'hidden';
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
btn.setAttribute('aria-expanded', isOpen);
|
||||
});
|
||||
Reference in New Issue
Block a user