{"version":3,"file":"CursorFollower.CJWd1AcE.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/b6CZYGjTzUTCrndYKKE6/FIOjf4d1V5lSQkmjQeAL/CursorFollower.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{motion,useMotionValue,useSpring}from\"framer-motion\";import{useEffect,useState}from\"react\";import{createPortal}from\"react-dom\";function calcX(clientX,imageWidth,offsetX,flipEdge){const distanceToRight=window.innerWidth-clientX;if(flipEdge&&distanceToRight<imageWidth){return clientX-imageWidth-offsetX;}return clientX+offsetX;}function Follower({startX,startY,imageWidth,imageHeight,heightMode,smoothness,fadeDuration,offsetX,offsetY,image,flipEdge,zIndex}){const stiffness=10+smoothness*1.9;const damping=10+smoothness*.4;const posX=useMotionValue(startX);const posY=useMotionValue(startY);const x=useSpring(posX,{stiffness,damping});const y=useSpring(posY,{stiffness,damping});useEffect(()=>{const onMove=e=>{posX.set(calcX(e.clientX,imageWidth,offsetX,flipEdge));posY.set(e.clientY+offsetY);};window.addEventListener(\"mousemove\",onMove);return()=>window.removeEventListener(\"mousemove\",onMove);},[offsetX,offsetY,imageWidth,flipEdge]);const resolvedHeight=heightMode===\"fixed\"?imageHeight:\"auto\";const content=/*#__PURE__*/_jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:fadeDuration,ease:\"easeOut\"},style:{position:\"fixed\",top:0,left:0,x,y,width:imageWidth,height:resolvedHeight,overflow:heightMode===\"fixed\"?\"hidden\":\"visible\",pointerEvents:\"none\",userSelect:\"none\",zIndex},children:image?/*#__PURE__*/_jsx(\"img\",{src:image,alt:\"\",draggable:false,style:{display:\"block\",width:imageWidth,height:heightMode===\"fixed\"?imageHeight:\"auto\",objectFit:heightMode===\"fixed\"?\"cover\":undefined}}):/*#__PURE__*/_jsx(\"div\",{style:{width:imageWidth,height:heightMode===\"fixed\"?imageHeight:imageWidth,borderRadius:\"50%\",background:\"rgba(255,255,255,0.15)\",border:\"2px solid rgba(255,255,255,0.6)\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",color:\"rgba(255,255,255,0.7)\",fontSize:11,fontFamily:\"monospace\",boxSizing:\"border-box\"},children:\"No image\"})});return /*#__PURE__*/createPortal(content,document.body);}export default function CursorFollower({image,imageWidth=120,heightMode=\"fit\",imageHeight=120,smoothness=30,fadeDuration=.4,offsetX=0,offsetY=0,flipEdge=true,zIndex=10}){const[cursorPos,setCursorPos]=useState(null);useEffect(()=>{const onFirst=e=>{setCursorPos({x:calcX(e.clientX,imageWidth,offsetX,flipEdge),y:e.clientY+offsetY});window.removeEventListener(\"mousemove\",onFirst);};window.addEventListener(\"mousemove\",onFirst);return()=>window.removeEventListener(\"mousemove\",onFirst);},[offsetX,offsetY,imageWidth,flipEdge]);if(!cursorPos)return null;return /*#__PURE__*/_jsx(Follower,{startX:cursorPos.x,startY:cursorPos.y,image:image,imageWidth:imageWidth,heightMode:heightMode,imageHeight:imageHeight,smoothness:smoothness,fadeDuration:fadeDuration,offsetX:offsetX,offsetY:offsetY,flipEdge:flipEdge,zIndex:zIndex});}addPropertyControls(CursorFollower,{image:{type:ControlType.Image,title:\"Image\"},imageWidth:{type:ControlType.Number,title:\"Width\",defaultValue:120,min:8,max:800,step:1,displayStepper:true},heightMode:{type:ControlType.Enum,title:\"Height\",options:[\"fit\",\"fixed\"],optionTitles:[\"Fit\",\"Fixed\"],defaultValue:\"fit\"},imageHeight:{type:ControlType.Number,title:\"Height (px)\",defaultValue:120,min:8,max:800,step:1,displayStepper:true,hidden:props=>props.heightMode!==\"fixed\"},smoothness:{type:ControlType.Number,title:\"Smoothness\",defaultValue:30,min:1,max:100,step:1,displayStepper:true,description:\"1 = very slow & smooth \\xb7 100 = nearly instant\"},fadeDuration:{type:ControlType.Number,title:\"Fade In\",defaultValue:.4,min:0,max:3,step:.05,displayStepper:true,description:\"Fade-in duration in seconds. Set 0 to disable.\"},offsetX:{type:ControlType.Number,title:\"Offset X\",defaultValue:0,min:-400,max:400,step:1,displayStepper:true,description:\"Offset from cursor. Auto-mirrors when image flips to right side.\"},offsetY:{type:ControlType.Number,title:\"Offset Y\",defaultValue:0,min:-400,max:400,step:1,displayStepper:true,description:\"Vertical offset from cursor. Negative = above.\"},flipEdge:{type:ControlType.Boolean,title:\"Flip at Edge\",defaultValue:true,description:\"Switches anchor from left to right when near the screen edge.\"},zIndex:{type:ControlType.Number,title:\"Z-Index\",defaultValue:10,min:-999,max:9999,step:1,displayStepper:true,description:\"Stack order. Lower = behind other elements.\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CursorFollower\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CursorFollower.map"],"mappings":"4QAAoO,SAAS,EAAM,EAAQ,EAAW,EAAQ,EAAS,CAAC,IAAM,EAAgB,EAAO,WAAW,EAAoF,OAAzE,GAAU,EAAgB,EAAmB,EAAQ,EAAW,EAAgB,EAAQ,EAAS,SAAS,EAAS,CAAC,SAAO,SAAO,aAAW,cAAY,aAAW,aAAW,eAAa,UAAQ,UAAQ,QAAM,WAAS,UAAQ,CAAC,IAAM,EAAU,GAAG,EAAW,IAAU,EAAQ,GAAG,EAAW,GAAS,EAAK,EAAe,EAAO,CAAO,EAAK,EAAe,EAAO,CAAO,EAAE,EAAU,EAAK,CAAC,YAAU,UAAQ,CAAC,CAAO,EAAE,EAAU,EAAK,CAAC,YAAU,UAAQ,CAAC,CAAC,MAAc,CAAC,IAAM,EAAO,GAAG,CAAC,EAAK,IAAI,EAAM,EAAE,QAAQ,EAAW,EAAQ,EAAS,CAAC,CAAC,EAAK,IAAI,EAAE,QAAQ,EAAQ,EAA+C,OAA5C,EAAO,iBAAiB,YAAY,EAAO,KAAW,EAAO,oBAAoB,YAAY,EAAO,EAAG,CAAC,EAAQ,EAAQ,EAAW,EAAS,CAAC,CAAC,IAAM,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