{"version":3,"file":"Custom_Cursor.BbO2oq5n.mjs","names":["useState","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,EAA6B,EAAO,CAAC,EAAO,GAAQ,EAAiB,EAAqC,EAAY,CAAC,UAAU,IAAI,QAAQ,EAAE,EAAQ,EAAE,EAAU,EAAO,CAAW,EAAQ,EAAE,EAAU,EAAO,CAAW,EAAgC,CAAC,EAAO,GAAWA,EAAS,EAAI,EAAiY,OAA5W,EAAoB,EAAO,SAAS,GAAQ,CAAC,IAAM,EAAE,EAAO,IAAI,EAAE,EAAU,GAAQ,IAAW,GAAQ,EAAO,WAAW,IAAW,GAAG,IAAW,GAAG,EAAO,YAAY,EAAS,CAAE,CAAC,EAAE,EAAoB,EAAO,SAAS,GAAQ,CAAC,IAAM,EAAE,EAAO,IAAI,EAAE,EAAU,GAAQ,IAAW,GAAQ,EAAO,YAAY,IAAW,GAAG,IAAW,GAAG,EAAO,WAAW,EAAS,CAAE,CAAC,EAAuB,EAAK,EAAU,CAAC,GAAG,EAAU,MAAI,QAAQ,CAAC,QAAQ,GAAU,EAAE,MAAM,CAAC,GAAG,EAAM,MAAM,IAAE,IAAE,QAAQ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