diff --git a/script.js b/script.js index edaa3c7..103ac97 100644 --- a/script.js +++ b/script.js @@ -11,8 +11,7 @@ document.addEventListener('DOMContentLoaded', () => { navigationLinks.forEach(navigationLink => { navigationLink.addEventListener('click', () => { - document.body.classList.remove('overflow-hidden'); - hamburgerCheckbox.checked = false; + closeNavigationMenu(); }); }); @@ -43,6 +42,19 @@ document.addEventListener('DOMContentLoaded', () => { } }); + // Close navigation menu when the dark overlay is clicked on + + const darkOverlay = navBar.querySelector('.bg-black'); + + darkOverlay.addEventListener('click', () => { + closeNavigationMenu(); + }); + + function closeNavigationMenu() { + document.body.classList.remove('overflow-hidden'); + hamburgerCheckbox.checked = false; + } + // particles.js particlesJS.load('faq', 'assets/particlesjs-config.json');