{"version":3,"file":"Rotate_Follow_Cursor.Bk305bAa.mjs","names":["useState","useRef"],"sources":["https:/framerusercontent.com/modules/qnrN6wkhz94Hv9gsiUQ3/PSxSrpFyIIHIQ5ZYuOBi/Rotate_Follow_Cursor.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useRef,useState}from\"react\";import{motion,useMotionValue}from\"framer-motion\";export function withFollowCursor(Component){return props=>{// Create a motion value for the rotation\nconst rotation=useMotionValue(0);// Create refs to store the cursor/touch position and the component reference\nconst[position,setPosition]=useState(null);const componentRef=useRef();// Update the position on mouse move or touch move\nconst handleMove=event=>{let x,y;if(event.changedTouches){// if this is a touch event\nx=event.changedTouches[0].clientX;y=event.changedTouches[0].clientY;}else{// if this is a mouse event\nx=event.clientX;y=event.clientY;}setPosition({x,y});};// Attach the move event listener to the window\nuseEffect(()=>{window.addEventListener(\"mousemove\",handleMove);window.addEventListener(\"touchmove\",handleMove);// Clean up the event listeners on unmount\nreturn()=>{window.removeEventListener(\"mousemove\",handleMove);window.removeEventListener(\"touchmove\",handleMove);};},[]);// Calculate the angle and update the rotation continuously\nuseEffect(()=>{const updateRotation=()=>{if(!componentRef.current||!position)return;const rect=componentRef.current.getBoundingClientRect();const centerX=rect.left+rect.width/2;const centerY=rect.top+rect.height/2;const deltaY=position.y-centerY;const deltaX=position.x-centerX;const angle=(Math.atan2(deltaY,deltaX)*(180/Math.PI)+360+90)%360;rotation.set(angle);requestAnimationFrame(updateRotation);};updateRotation();},[position]);return /*#__PURE__*/_jsx(Component,{...props,ref:componentRef,as:motion.div,style:{...props.style,rotate:rotation,transformOrigin:\"center\"}});};}\nexport const __FramerMetadata__ = {\"exports\":{\"withFollowCursor\":{\"type\":\"reactHoc\",\"name\":\"withFollowCursor\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Rotate_Follow_Cursor.map"],"mappings":"uTAAyI,SAAgB,EAAiB,EAAU,CAAC,MAAO,IAAO,CACnM,IAAM,EAAS,EAAe,EAAE,CAC3B,CAAC,EAAS,GAAaA,EAAS,KAAK,CAAO,EAAaC,GAAQ,CAChE,EAAW,GAAO,CAAC,IAAI,EAAE,EAAK,EAAM,gBAC1C,EAAE,EAAM,eAAe,GAAG,QAAQ,EAAE,EAAM,eAAe,GAAG,UAC5D,EAAE,EAAM,QAAQ,EAAE,EAAM,SAAS,EAAY,CAAC,IAAE,IAAE,CAAC,EAG+X,OAFlb,OAAe,EAAO,iBAAiB,YAAY,EAAW,CAAC,EAAO,iBAAiB,YAAY,EAAW,KACpG,CAAC,EAAO,oBAAoB,YAAY,EAAW,CAAC,EAAO,oBAAoB,YAAY,EAAW,GAAK,EAAE,CAAC,CACxH,MAAc,CAAC,IAAM,MAAmB,CAAC,GAAG,CAAC,EAAa,SAAS,CAAC,EAAS,OAAO,IAAM,EAAK,EAAa,QAAQ,uBAAuB,CAAO,EAAQ,EAAK,KAAK,EAAK,MAAM,EAAQ,EAAQ,EAAK,IAAI,EAAK,OAAO,EAAQ,EAAO,EAAS,EAAE,EAAc,EAAO,EAAS,EAAE,EAAc,GAAO,KAAK,MAAM,EAAO,EAAO,EAAE,IAAI,KAAK,IAAI,IAAI,IAAI,IAAI,EAAS,IAAI,EAAM,CAAC,sBAAsB,EAAe,EAAG,GAAgB,EAAG,CAAC,EAAS,CAAC,CAAqB,EAAK,EAAU,CAAC,GAAG,EAAM,IAAI,EAAa,GAAG,EAAO,IAAI,MAAM,CAAC,GAAG,EAAM,MAAM,OAAO,EAAS,gBAAgB,SAAS,CAAC,CAAC,uBARphB,IAA6C,IAAiD"}