Skip to content

Commit

Permalink
Add No scrolling to body while the Hamburger is opened
Browse files Browse the repository at this point in the history
  • Loading branch information
Sayan67 committed Mar 15, 2024
1 parent 65696f4 commit 13f06a4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion client/component/Navbar/MobileNavbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ const MobileNavbar = () => {
const [shouldMorph, setMorph] = useState(false);

const handleToggle = () => {
document.body.style.overflow = isOpen ? 'auto' : 'hidden';
setIsOpen(!isOpen);
};

useEffect(() => {

const trigger = document.createElement('div')
trigger.style.position = 'absolute';
trigger.style.top = '0';
Expand All @@ -39,6 +39,7 @@ const MobileNavbar = () => {
useEffect(() => {
// Hide the mobile navbar when the url changes.
setIsOpen(false)
document.body.style.overflow = 'scroll'
}, [urlPathname])

return (
Expand Down
7 changes: 5 additions & 2 deletions client/styles/Navbar.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@
z-index: 9999999999;
position: fixed;
top: 0;
width: 100vw;
height: 100vh;
overflow: hidden;
}

.Hamburger_icon {
Expand Down Expand Up @@ -204,8 +207,8 @@
}

.BlurBackground {
width: 100vw;
height: 100vh;
width: 100%;
height: 100%;
position: absolute;
z-index: -1;
top: 0;
Expand Down
2 changes: 1 addition & 1 deletion client/styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ a {
body {
background-color: var(--backGround);
font-family: 'quaz';
/* overflow: hidden; */
overflow: scroll;
}

.register_text {
Expand Down

0 comments on commit 13f06a4

Please sign in to comment.