{"version":3,"file":"CursorTrail.BjMA4MZ4.mjs","names":["useState","useRef"],"sources":["https:/framerusercontent.com/modules/prXJdN8MxY6U0GakVC63/nvRcfG5pu50CO3ZWbj6s/CursorTrail.js"],"sourcesContent":["// Mouse grid tail effect with fading squares following the mouse, positioned on an invisible grid. Square size is user-controllable.\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useRef,useEffect,useState,startTransition}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";/**\n *\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n * @framerDisableUnlink\n */export default function CursorTrail(props){const{squareSize,fadeDuration,color,maxSquares,shape,style}=props;const[squares,setSquares]=useState([]);const isStatic=useIsStaticRenderer();const keyRef=useRef(0);const rafRef=useRef();// Mouse move handler\nuseEffect(()=>{if(isStatic)return;function handle(e){const rect=e.target?.getBoundingClientRect?.()||{left:0,top:0};// Snap to grid\nconst x=Math.floor((e.clientX-rect.left)/squareSize)*squareSize;const y=Math.floor((e.clientY-rect.top)/squareSize)*squareSize;const now=Date.now();startTransition(()=>{setSquares(prev=>{// Avoid duplicate squares at same grid position\nif(prev.length>0){const last=prev[prev.length-1];if(last.x===x&&last.y===y)return prev;}const next=[...prev,{x,y,key:keyRef.current++,created:now}];// Limit to maxSquares\nreturn next.slice(-maxSquares);});});}window.addEventListener(\"mousemove\",handle);return()=>window.removeEventListener(\"mousemove\",handle);},[squareSize,maxSquares,isStatic]);// Remove old squares\nuseEffect(()=>{if(isStatic)return;function clean(){const now=Date.now();startTransition(()=>{setSquares(prev=>prev.filter(sq=>now-sq.created<fadeDuration));});rafRef.current=requestAnimationFrame(clean);}rafRef.current=requestAnimationFrame(clean);return()=>rafRef.current&&cancelAnimationFrame(rafRef.current);},[fadeDuration,isStatic]);// Render squares\nreturn /*#__PURE__*/_jsx(\"div\",{style:{...style,position:\"relative\",width:\"100%\",height:\"100%\",overflow:\"hidden\",pointerEvents:\"none\"},children:squares.map(sq=>{const age=Date.now()-sq.created;const opacity=1-Math.min(1,age/fadeDuration);return /*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",left:sq.x,top:sq.y,width:squareSize,height:squareSize,background:color,opacity,borderRadius:shape===\"circle\"?\"50%\":0,pointerEvents:\"none\",transition:\"opacity 0.2s linear\",willChange:\"opacity\"},\"aria-hidden\":\"true\"},sq.key);})});}addPropertyControls(CursorTrail,{shape:{type:ControlType.Enum,title:\"Shape\",description:\"Shape of the trail elements.\",options:[\"square\",\"circle\"],optionTitles:[\"Square\",\"Circle\"],defaultValue:\"square\",displaySegmentedControl:true},squareSize:{type:ControlType.Number,title:\"Size\",description:\"Size of the shapes.\",defaultValue:32,min:8,max:128,step:1,unit:\"px\"},fadeDuration:{type:ControlType.Number,title:\"Fade\",description:\"How long squares take to fade out (ms).\",defaultValue:700,min:100,max:3e3,step:50,unit:\"ms\"},color:{type:ControlType.Color,title:\"Color\",description:\"Color of the squares.\",defaultValue:\"#222\"},maxSquares:{type:ControlType.Number,title:\"Tail\",description:\"Maximum number of squares in the tail.\",defaultValue:30,min:5,max:100,step:1}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CursorTrail\",\"slots\":[],\"annotations\":{\"framerDisableUnlink\":\"\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CursorTrail.map"],"mappings":"qNAOG,SAAwB,EAAY,EAAM,CAAC,GAAK,CAAC,aAAW,eAAa,QAAM,aAAW,QAAM,SAAO,EAAW,CAAC,EAAQ,GAAYA,EAAS,EAAE,CAAC,CAAO,EAAS,GAAqB,CAAO,EAAOC,EAAO,EAAE,CAAO,EAAOA,GAAQ,CAMxO,OALA,MAAc,CAAC,GAAG,EAAS,OAAO,SAAS,EAAO,EAAE,CAAC,IA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