// Hamburger menu for mobile navigation document.addEventListener('DOMContentLoaded', function () { const menu = document.querySelector('.hamburger-menu'); const sidebarContainer = document.querySelector('.sidebar-container'); function toggleMenu() { // Toggle the hamburger menu menu.querySelector('svg').classList.toggle('open'); // When the menu is open, we want to show the navigation sidebar sidebarContainer.classList.toggle('hx:max-md:[transform:translate3d(0,-100%,0)]'); sidebarContainer.classList.toggle('hx:max-md:[transform:translate3d(0,0,0)]'); // When the menu is open, we want to prevent the body from scrolling document.body.classList.toggle('hx:overflow-hidden'); document.body.classList.toggle('hx:md:overflow-auto'); } menu.addEventListener('click', (e) => { e.preventDefault(); toggleMenu(); }); // Select all anchor tags in the sidebar container const sidebarLinks = sidebarContainer.querySelectorAll('a'); // Add click event listener to each anchor tag sidebarLinks.forEach(link => { link.addEventListener('click', (e) => { // Check if the href attribute contains a hash symbol (links to a heading) if (link.getAttribute('href') && link.getAttribute('href').startsWith('#')) { // Only dismiss overlay on mobile view if (window.innerWidth < 768) { toggleMenu(); } } }); }); });