[feat] attempt to reduce laggy animation
This commit is contained in:
parent
87c1ec1b82
commit
2ce97cccb9
1 changed files with 32 additions and 18 deletions
|
|
@ -6,14 +6,16 @@ import Link from "next/link";
|
||||||
const NavItems = ({ isNavOpen, setIsNavOpen }) => {
|
const NavItems = ({ isNavOpen, setIsNavOpen }) => {
|
||||||
const [isMobile, setIsMobile] = useState(false);
|
const [isMobile, setIsMobile] = useState(false);
|
||||||
|
|
||||||
const handleItemClick = () => {
|
const handleItemClick = () => {
|
||||||
setIsNavOpen(false);
|
setIsNavOpen(false);
|
||||||
};
|
};
|
||||||
const navVariant = {
|
const navVariant = {
|
||||||
open: {
|
open: {
|
||||||
clipPath: `circle(1920px at calc(100% - 40px) 40px)`,
|
clipPath: `circle(1920px at calc(100% - 40px) 40px)`,
|
||||||
transition: {
|
transition: {
|
||||||
type: "tween", // Use a linear or ease transition
|
type: "spring",
|
||||||
|
stiffness: 400,
|
||||||
|
damping: 40,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
closed: {
|
closed: {
|
||||||
|
|
@ -43,25 +45,39 @@ const NavItems = ({ isNavOpen, setIsNavOpen }) => {
|
||||||
|
|
||||||
// Check screen width and adjust clipPath for smaller screens
|
// Check screen width and adjust clipPath for smaller screens
|
||||||
if (isMobile) {
|
if (isMobile) {
|
||||||
navVariant.closed = {
|
(navVariant.open = {
|
||||||
clipPath: "circle(0px at calc(100% - 35px) 35px)",
|
clipPath: `circle(1920px at calc(100% - 40px) 40px)`,
|
||||||
transition: {
|
transition: {
|
||||||
delay: 0.5,
|
type: "tween",
|
||||||
type: "spring",
|
|
||||||
stiffness: 400,
|
|
||||||
damping: 40,
|
|
||||||
},
|
},
|
||||||
};
|
}),
|
||||||
|
(navVariant.closed = {
|
||||||
|
clipPath: "circle(0px at calc(100% - 35px) 35px)",
|
||||||
|
transition: {
|
||||||
|
delay: 0.5,
|
||||||
|
type: "spring",
|
||||||
|
stiffness: 400,
|
||||||
|
damping: 40,
|
||||||
|
},
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
navVariant.closed = {
|
(navVariant.open = {
|
||||||
clipPath: "circle(0px at calc(100% - 120px) 35px)",
|
clipPath: `circle(1920px at calc(100% - 40px) 40px)`,
|
||||||
transition: {
|
transition: {
|
||||||
delay: 0.5,
|
|
||||||
type: "spring",
|
type: "spring",
|
||||||
stiffness: 400,
|
stiffness: 400,
|
||||||
damping: 40,
|
damping: 40,
|
||||||
},
|
},
|
||||||
};
|
}),
|
||||||
|
(navVariant.closed = {
|
||||||
|
clipPath: "circle(0px at calc(100% - 120px) 35px)",
|
||||||
|
transition: {
|
||||||
|
delay: 0.5,
|
||||||
|
type: "spring",
|
||||||
|
stiffness: 400,
|
||||||
|
damping: 40,
|
||||||
|
},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
const itemVariants = {
|
const itemVariants = {
|
||||||
open: {
|
open: {
|
||||||
|
|
@ -180,9 +196,7 @@ const Navbar = () => {
|
||||||
<div>
|
<div>
|
||||||
<h1
|
<h1
|
||||||
className={`text-2xl ml-2 md:ml-0 ${
|
className={`text-2xl ml-2 md:ml-0 ${
|
||||||
isNavOpen
|
isNavOpen ? "text-white" : ""
|
||||||
? "text-white"
|
|
||||||
: ""
|
|
||||||
}`}>
|
}`}>
|
||||||
Alvalens
|
Alvalens
|
||||||
</h1>
|
</h1>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue