diff --git a/frontend/src/components/Hero.tsx b/frontend/src/components/Hero.tsx index dbe2245..0cd3927 100644 --- a/frontend/src/components/Hero.tsx +++ b/frontend/src/components/Hero.tsx @@ -5,6 +5,7 @@ import { Globe } from "@/components/ui/globe"; import { OrbitSatellites } from "@/components/ui/OrbitSatellites"; import { ShimmerButton } from "@/components/ui/shimmer-button"; import { Link } from "react-router-dom"; +import { MouseParallax } from "./MouseParallax"; const TELEMETRY = [ { label: "OBJECTS TRACKED", value: "34,900+" }, @@ -25,16 +26,23 @@ const fadeUp = { export function Hero() { return (
- + + + + +
- -
+ + + + + -
+
diff --git a/frontend/src/components/MouseParallax.tsx b/frontend/src/components/MouseParallax.tsx new file mode 100644 index 0000000..d64dc09 --- /dev/null +++ b/frontend/src/components/MouseParallax.tsx @@ -0,0 +1,59 @@ +import {useRef, type ReactNode} from "react"; +import {motion, useMotionValue, useSpring} from "framer-motion" + +interface MouseParallaxProps { + children: ReactNode; + strength?: number; + className?: string; + springConfig?: { + stiffness?: number; + damping?: number; + mass?: number; + }; + } + +export function MouseParallax({ + children, + strength = 20, + className="", + springConfig = {stiffness: 150, damping: 15, mass: 0.1}, +}: MouseParallaxProps) { + const ref = useRef(null); + + const x = useMotionValue(0); + const y = useMotionValue(0); + + const springX = useSpring(x, springConfig); + const springY = useSpring(y, springConfig); + + const handleMouseMove = (e: React.MouseEvent) => { + const rect = ref.current?.getBoundingClientRect(); + if (!rect) return; + + const centerX = rect.left + rect.width / 2; + const centerY = rect.top + rect.height / 2; + + const offsetX = (e.clientX - centerX) / (rect.width / 2); + const offsetY = (e.clientY - centerY) / (rect.height / 2); + + x.set(offsetX * strength); + y.set(offsetY * strength); + }; + + const handleMouseLeave = () => { + x.set(0); + y.set(0); + }; + + return ( + + {children} + + ) +} \ No newline at end of file