{"version":3,"file":"CursorFollower.BFbRBlup.mjs","names":["_jsx","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,CAAQ,CAAC,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,CAAM,EAAQ,EAAK,EAAe,CAAM,EAAQ,EAAE,EAAU,EAAK,CAAC,YAAU,SAAO,CAAC,EAAQ,EAAE,EAAU,EAAK,CAAC,YAAU,SAAO,CAAC,EAAE,MAAc,CAAC,IAAM,EAAO,GAAG,CAAC,EAAK,IAAI,EAAM,EAAE,QAAQ,EAAW,EAAQ,CAAQ,CAAC,EAAE,EAAK,IAAI,EAAE,QAAQ,CAAO,CAAE,EAA8C,OAA5C,EAAO,iBAAiB,YAAY,CAAM,MAAY,EAAO,oBAAoB,YAAY,CAAM,CAAE,EAAE,CAAC,EAAQ,EAAQ,EAAW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