Skip to content

Commit

Permalink
Fixed detached NavbarMenu scrolling bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin-Kwan committed Dec 19, 2023
1 parent 73db5a5 commit 99c03ac
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions components/NavbarMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useEffect } from 'react';
import { motion } from 'framer-motion';
import Link from 'next/link';

Expand All @@ -7,12 +8,16 @@ type MenuProps = {
};

const NavbarMenu = ({ isMenuOpen, toggleMenu }: MenuProps) => {
useEffect(() => {
// If the menu is being opened, prevent scrolling. Otherwise, allow it.
document.body.style.overflow = isMenuOpen ? 'hidden' : 'auto';
}, [isMenuOpen]);
return (
<motion.div
style={{ zIndex: 5, backgroundColor: '#171F29' }}
style={{ zIndex: 5, backgroundColor: '#171F29', paddingTop: '64px' }}
className={`${
isMenuOpen ? 'block' : 'hidden'
} fixed text-white w-full flex justify-center text-center md:hidden mt-16`}
} fixed text-white w-full flex justify-center text-center md:hidden`}
initial={{ y: '-100vh' }}
animate={{ y: isMenuOpen ? '0' : '-100vh' }}
transition={{ duration: 0.3 }}
Expand Down

0 comments on commit 99c03ac

Please sign in to comment.