Skip to content

Commit

Permalink
add menu state
Browse files Browse the repository at this point in the history
  • Loading branch information
yohn-maistre committed Oct 24, 2024
1 parent 0002f9c commit 1c92db2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/css/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
font-size: 15px;
}

body, html {
overflow: hidden;
}

body {
margin: 0;
--color-text: #000;
Expand Down
11 changes: 11 additions & 0 deletions src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ let isAnimating = false;
const openMenu = () => {
if (isAnimating) return;
isAnimating = true;
localStorage.setItem('menuOpen', 'true');
gsap.timeline({
onComplete: () => isAnimating = false
})
Expand Down Expand Up @@ -94,6 +95,7 @@ const openMenu = () => {
const closeMenu = () => {
if (isAnimating) return;
isAnimating = true;
localStorage.setItem('menuOpen', 'false');
gsap.timeline({
onComplete: () => isAnimating = false
})
Expand Down Expand Up @@ -158,6 +160,15 @@ menuWrap.addEventListener('wheel', (e) => {
}
});

// Check the menu state on page load
document.addEventListener('DOMContentLoaded', () => {
const menuOpen = localStorage.getItem('menuOpen');
if (menuOpen === 'true') {
frame.classList.add('frame--menu-open');
menuWrap.classList.add('menu-wrap--open');
}
});

// Optional: Close menu on escape key press
document.addEventListener('keydown', (e) => {
if (e.key === 'Escape' && menuWrap.classList.contains('menu-wrap--open')) {
Expand Down

0 comments on commit 1c92db2

Please sign in to comment.