"use client"; import { motion, useMotionValue, useTransform, useSpring } from "framer-motion"; import { useEffect, useState } from "react"; const BackgroundBlobs = () => { const mouseX = useMotionValue(0); const mouseY = useMotionValue(0); const springConfig = { damping: 50, stiffness: 50, mass: 2 }; const springX = useSpring(mouseX, springConfig); const springY = useSpring(mouseY, springConfig); // Very subtle parallax offsets const x1 = useTransform(springX, (value) => value / 30); const y1 = useTransform(springY, (value) => value / 30); const x2 = useTransform(springX, (value) => value / -25); const y2 = useTransform(springY, (value) => value / -25); const x3 = useTransform(springX, (value) => value / 20); const y3 = useTransform(springY, (value) => value / 20); const x4 = useTransform(springX, (value) => value / -35); const y4 = useTransform(springY, (value) => value / -35); const x5 = useTransform(springX, (value) => value / 15); const y5 = useTransform(springY, (value) => value / 15); // Prevent hydration mismatch const [mounted, setMounted] = useState(false); useEffect(() => { setMounted(true); }, []); useEffect(() => { if (!mounted) return; const handleMouseMove = (e: MouseEvent) => { const x = e.clientX - window.innerWidth / 2; const y = e.clientY - window.innerHeight / 2; mouseX.set(x); mouseY.set(y); }; window.addEventListener("mousemove", handleMouseMove); return () => window.removeEventListener("mousemove", handleMouseMove); }, [mouseX, mouseY, mounted]); if (!mounted) return null; return (
{/* Mint blob - top left */} {/* Lavender blob - top right */} {/* Rose blob - bottom left */} {/* Peach blob - middle right */} {/* Blue blob - center */} {/* Pink blob - bottom right */} {/* Yellow-green blob - top center */}
); }; export default BackgroundBlobs;