'use client'; import React, { useRef, useEffect } from 'react'; import { useScroll, useTransform, useSpring, m } from 'framer-motion'; import { LogoArcs } from '@/components/ui/LogoArcs'; function MagneticRing({ children, className, pullStrength = 30, // How strong the pull is (higher = moves closer to mouse) pullRadius = 600 // Distance from center at which it starts pulling }: { children: React.ReactNode, className?: string, pullStrength?: number, pullRadius?: number }) { const ref = useRef(null); // Spring physics for extremely smooth, organic movement const x = useSpring(0, { stiffness: 40, damping: 25, mass: 1 }); const y = useSpring(0, { stiffness: 40, damping: 25, mass: 1 }); useEffect(() => { // Only run on client with mouse if (window.matchMedia("(pointer: coarse)").matches) return; let ticking = false; const handleMouseMove = (e: MouseEvent) => { if (!ref.current) return; if (!ticking) { window.requestAnimationFrame(() => { if (!ref.current) { ticking = false; return; } const rect = ref.current.getBoundingClientRect(); const centerX = rect.left + rect.width / 2; const centerY = rect.top + rect.height / 2; const distX = e.clientX - centerX; const distY = e.clientY - centerY; const actualDistance = Math.sqrt(distX * distX + distY * distY); if (actualDistance < pullRadius) { // Exponential falloff for natural magnetic feel const pullFactor = Math.pow(1 - (actualDistance / pullRadius), 2); // Target offset (fraction of the distance based on strength) x.set(distX * pullFactor * (pullStrength / 100)); y.set(distY * pullFactor * (pullStrength / 100)); } else { // Return to origin smoothly x.set(0); y.set(0); } ticking = false; }); ticking = true; } }; window.addEventListener('mousemove', handleMouseMove, { passive: true }); return () => window.removeEventListener('mousemove', handleMouseMove); }, [x, y, pullRadius, pullStrength]); return ( {children} ); } export function CorporateBackground() { const { scrollYProgress } = useScroll(); // Stronger parallax offsets for visible movement const y1 = useTransform(scrollYProgress, [0, 1], [0, -400]); const y2 = useTransform(scrollYProgress, [0, 1], [0, 500]); const y3 = useTransform(scrollYProgress, [0, 1], [0, -600]); const y4 = useTransform(scrollYProgress, [0, 1], [0, 350]); const y5 = useTransform(scrollYProgress, [0, 1], [0, -500]); return ( ); }