Initial commit
This commit is contained in:
20
static/js/hamburger.js
Normal file
20
static/js/hamburger.js
Normal file
@@ -0,0 +1,20 @@
|
||||
(function () {
|
||||
var btn = document.getElementById('nav-hamburger');
|
||||
var drawer = document.getElementById('nav-drawer');
|
||||
if (!btn || !drawer) return;
|
||||
|
||||
btn.addEventListener('click', function () {
|
||||
var isOpen = drawer.classList.toggle('open');
|
||||
btn.classList.toggle('open', isOpen);
|
||||
btn.setAttribute('aria-expanded', String(isOpen));
|
||||
});
|
||||
|
||||
// Ferme le drawer quand on clique sur un lien
|
||||
drawer.querySelectorAll('a').forEach(function (a) {
|
||||
a.addEventListener('click', function () {
|
||||
drawer.classList.remove('open');
|
||||
btn.classList.remove('open');
|
||||
btn.setAttribute('aria-expanded', 'false');
|
||||
});
|
||||
});
|
||||
})();
|
||||
Reference in New Issue
Block a user