Skip to content

Commit 66fdf23

Browse files
committed
Use framer motion instead to animate the svg
1 parent db17007 commit 66fdf23

1 file changed

Lines changed: 20 additions & 17 deletions

File tree

apps/webapp/app/components/navigation/SideMenu.tsx

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -820,49 +820,52 @@ function AnimatedChevron({
820820
};
821821

822822
return (
823-
<svg
823+
<motion.svg
824824
width="4"
825825
height="30"
826826
viewBox="0 0 4 30"
827827
fill="none"
828828
xmlns="http://www.w3.org/2000/svg"
829-
className="overflow-visible text-charcoal-600 group-hover:text-text-bright transition-colors"
830-
style={{
831-
transform: `translateX(${getTranslateX()}px)`,
832-
transition: "transform 400ms ease-out",
829+
className="pointer-events-none relative z-10 overflow-visible text-charcoal-600 group-hover:text-text-bright transition-colors"
830+
initial={false}
831+
animate={{
832+
x: getTranslateX(),
833833
}}
834+
transition={{ duration: 0.4, ease: "easeOut" }}
834835
>
835836
{/* Top segment */}
836-
<line
837+
<motion.line
837838
x1="2"
838839
y1="1.5"
839840
x2="2"
840841
y2="15"
841842
stroke="currentColor"
842843
strokeWidth="3"
843844
strokeLinecap="round"
844-
style={{
845-
transformOrigin: "2px 15px",
846-
transform: `rotate(${top}deg)`,
847-
transition: "transform 200ms ease-out",
845+
initial={false}
846+
animate={{
847+
rotate: top,
848848
}}
849+
transition={{ duration: 0.2, ease: "easeOut" }}
850+
style={{ transformOrigin: "2px 15px" }}
849851
/>
850852
{/* Bottom segment */}
851-
<line
853+
<motion.line
852854
x1="2"
853855
y1="15"
854856
x2="2"
855857
y2="28.5"
856858
stroke="currentColor"
857859
strokeWidth="3"
858860
strokeLinecap="round"
859-
style={{
860-
transformOrigin: "2px 15px",
861-
transform: `rotate(${bottom}deg)`,
862-
transition: "transform 200ms ease-out",
861+
initial={false}
862+
animate={{
863+
rotate: bottom,
863864
}}
865+
transition={{ duration: 0.2, ease: "easeOut" }}
866+
style={{ transformOrigin: "2px 15px" }}
864867
/>
865-
</svg>
868+
</motion.svg>
866869
);
867870
}
868871

@@ -878,7 +881,7 @@ function CollapseToggle({
878881
return (
879882
<div className="absolute -right-3 top-1/2 z-10 -translate-y-1/2">
880883
{/* Vertical line to mask the side menu border */}
881-
<div className="absolute left-1/2 top-1/2 h-10 w-px -translate-y-1/2 bg-background-bright" />
884+
<div className="pointer-events-none absolute left-1/2 top-1/2 h-10 w-px -translate-y-1/2 bg-background-bright" />
882885
<TooltipProvider disableHoverableContent>
883886
<Tooltip>
884887
<TooltipTrigger asChild>

0 commit comments

Comments
 (0)