Skip to content

Commit 44424c5

Browse files
committed
Update MobileMenu.component.tsx
1 parent 953bd0d commit 44424c5

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

src/components/Layout/MobileMenu.component.tsx

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ const MobileMenu = ({ links }: IMobileMenuProps) => {
3636
type: "spring",
3737
stiffness: 400,
3838
damping: 40,
39+
delay: 0.2, // Delay the menu closing to allow text to fade out first
3940
},
4041
},
4142
open: {
@@ -53,7 +54,10 @@ const MobileMenu = ({ links }: IMobileMenuProps) => {
5354
x: i % 2 === 0 ? "-100%" : "100%",
5455
opacity: 0,
5556
transition: {
56-
delay: 0.15,
57+
type: "spring",
58+
stiffness: 300,
59+
damping: 24,
60+
duration: 0.15,
5761
},
5862
}),
5963
open: (i: number) => ({
@@ -82,14 +86,27 @@ const MobileMenu = ({ links }: IMobileMenuProps) => {
8286
data-testid="mobile-menu"
8387
data-cy="mobile-menu"
8488
aria-hidden={!isExpanded}
85-
className="fixed top-0 right-0 w-screen h-screen bg-gray-800 flex items-center justify-center -z-50"
89+
className="fixed top-0 right-0 w-screen h-screen bg-gray-800 flex items-center justify-center -z-10"
8690
initial="closed"
8791
animate="open"
8892
exit="closed"
8993
variants={menuVariants}
9094
>
9195
<nav aria-label="Navigasjon" className="w-full">
92-
<ul className="w-full">
96+
<motion.ul
97+
className="w-full"
98+
initial="closed"
99+
animate="open"
100+
exit="closed"
101+
variants={{
102+
open: {
103+
transition: { staggerChildren: 0.07, delayChildren: 0.2 }
104+
},
105+
closed: {
106+
transition: { staggerChildren: 0.05, staggerDirection: -1 }
107+
}
108+
}}
109+
>
93110
{links.map(({ title, name, hash, href }, index) => (
94111
<motion.li
95112
key={title}
@@ -119,7 +136,7 @@ const MobileMenu = ({ links }: IMobileMenuProps) => {
119136
)}
120137
</motion.li>
121138
))}
122-
</ul>
139+
</motion.ul>
123140
</nav>
124141
</motion.div>
125142
)}
@@ -128,4 +145,4 @@ const MobileMenu = ({ links }: IMobileMenuProps) => {
128145
);
129146
};
130147

131-
export default MobileMenu;
148+
export default MobileMenu;

0 commit comments

Comments
 (0)