{"version":3,"file":"Custom_Cursor.DbQRAYw2.mjs","names":["useState","y","x","useRef"],"sources":["https:/framerusercontent.com/modules/M5IvbW7b7WItEXklrWJO/vNLHoYnSgTXfiowntFjQ/Custom_Cursor.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useState,useEffect,useRef}from\"react\";import{useMotionValue,useSpring,useMotionValueEvent}from\"framer-motion\";// Apply this override to object you want to follow the mouse\nexport function withFollowMouse(Component){return props=>{const[rect,ref]=useElementBoundingClientRect();const[mouseX,mouseY]=useMousePosition();/* useSpring MotionValues */ const springValue={stiffness:400,damping:30};const x=useSpring(mouseX,springValue);const y=useSpring(mouseY,springValue);return /*#__PURE__*/ _jsx(Component,{...props,ref:ref,style:{...props.style,x,y,position:\"fixed\",// align center of component to mouse pointer\ntop:-rect.height/2,left:-rect.width/2,pointerEvents:\"none\"}});};}// Apply this override to object you want to follow the mouse\nexport function withFollowMouseHideOffScreen(Component){return props=>{const[rect,ref]=useElementBoundingClientRect();const[mouseX,mouseY]=useMousePosition();/* useSpring MotionValues */ const springValue={stiffness:500,damping:50};const x=useSpring(mouseX,springValue);const y=useSpring(mouseY,springValue);/* Hide if off screen */ const[hidden,setHidden]=useState(true);const tolerance=10;useMotionValueEvent(mouseX,\"change\",latest=>{const y=mouseY.get();setHidden(latest<=tolerance||latest>=window.innerWidth-tolerance||y<=tolerance||y>=window.innerHeight-tolerance);});useMotionValueEvent(mouseY,\"change\",latest=>{const x=mouseX.get();setHidden(latest<=tolerance||latest>=window.innerHeight-tolerance||x<=tolerance||x>=window.innerWidth-tolerance);});return /*#__PURE__*/ _jsx(Component,{...props,ref:ref,animate:{opacity:hidden?0:1},style:{...props.style,x,y,opacity:0,position:\"fixed\",// align center of component to mouse pointer\ntop:-rect.height/2,left:-rect.width/2,pointerEvents:\"none\"}});};}function useMousePosition(){const mouseX=useMotionValue(0);const mouseY=useMotionValue(0);useEffect(()=>{const handleMouseMove=event=>{mouseX.set(event.clientX);mouseY.set(event.clientY);};window.addEventListener(\"mousemove\",handleMouseMove);return()=>{window.removeEventListener(\"mousemove\",handleMouseMove);};},[]);return[mouseX,mouseY];}function useElementBoundingClientRect(){const ref=useRef(null);const[rect,setRect]=useState({x:0,y:0,left:0,right:200,top:0,bottom:200,width:200,height:200});useEffect(()=>{if(ref.current){setRect(ref.current.getBoundingClientRect());}},[]);return[rect,ref];}\nexport const __FramerMetadata__ = {\"exports\":{\"withFollowMouseHideOffScreen\":{\"type\":\"reactHoc\",\"name\":\"withFollowMouseHideOffScreen\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withFollowMouse\":{\"type\":\"reactHoc\",\"name\":\"withFollowMouse\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Custom_Cursor.map"],"mappings":"wMAGA,SAAgB,EAA6B,EAAU,CAAC,MAAO,IAAO,CAAC,GAAK,CAAC,EAAK,GAAK,GAA8B,CAAM,CAAC,EAAO,GAAQ,GAAkB,CAAoC,EAAY,CAAC,UAAU,IAAI,QAAQ,GAAG,CAAO,EAAE,EAAU,EAAO,EAAY,CAAO,EAAE,EAAU,EAAO,EAAY,CAA+B,CAAC,EAAO,GAAWA,EAAS,GAAK,CAAgY,OAA5W,EAAoB,EAAO,SAAS,GAAQ,CAAC,IAAMC,EAAE,EAAO,KAAK,CAAC,EAAU,GAAQ,IAAW,GAAQ,EAAO,WAAW,IAAWA,GAAG,IAAWA,GAAG,EAAO,YAAY,GAAU,EAAG,CAAC,EAAoB,EAAO,SAAS,GAAQ,CAAC,IAAMC,EAAE,EAAO,KAAK,CAAC,EAAU,GAAQ,IAAW,GAAQ,EAAO,YAAY,IAAWA,GAAG,IAAWA,GAAG,EAAO,WAAW,GAAU,EAAG,CAAsB,EAAK,EAAU,CAAC,GAAG,EAAU,MAAI,QAAQ,CAAC,QAAQ,EAAO,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,EAAM,MAAM,IAAE,IA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