Skip to content

Commit

Permalink
Update script.js
Browse files Browse the repository at this point in the history
  • Loading branch information
mehrdadmsv authored May 25, 2024
1 parent 2675dbe commit 72b727a
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,24 @@ document.addEventListener("DOMContentLoaded", function () {
const sections = document.querySelectorAll(".section");

function toggleMenu() {
const topnav = document.getElementById("topnav");
const close = document.getElementById("close");
const hamburger = document.getElementById("hamburger");

topnav.classList.toggle("active");
body.classList.toggle("no-scroll");

// Hide or show sections based on the menu state
if (body.classList.contains("no-scroll")) {
sections.forEach(section => section.style.display = "none");

// Prevent scrolling while menu is open
if (topnav.classList.contains("active")) {
document.body.style.overflow = "hidden";
} else {
setTimeout(() => {
sections.forEach(section => section.style.display = "flex");
}, 500); // Adjust this delay to match your menu transition duration
document.body.style.overflow = "auto";
}


// Show/hide hamburger and close icons based on menu state
hamburger.style.display = hamburger.style.display === 'none' ? 'block' : 'none';
close.style.display = close.style.display === 'block' ? 'none' : 'block';
}


function checkScreenSize() {
if (window.innerWidth > 768) {
Expand Down

0 comments on commit 72b727a

Please sign in to comment.