{"version":3,"file":"MouseStickerBackground.DeAjAEcH.mjs","names":["useState","useRef","now"],"sources":["https:/framerusercontent.com/modules/XrJVg7Rio3brn55RGiEZ/7mtkxnavoIht5qawg5Ih/MouseStickerBackground.js"],"sourcesContent":["// Sticker background: places a random image from an input list at the mouse position on every mouse move, with per-sticker variable fade out\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useRef,useState,useEffect,startTransition}from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";/**\n * MouseStickerBackground\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function MouseStickerBackground(props){const{images=[{src:\"https://framerusercontent.com/images/GfGkADagM4KEibNcIiRUWlfrR0.jpg\",alt:\"Sticker 1\",size:64,decay:1200},{src:\"https://framerusercontent.com/images/aNsAT3jCvt4zglbWCUoFe33Q.jpg\",alt:\"Sticker 2\",size:64,decay:1200},{src:\"https://framerusercontent.com/images/BYnxEV1zjYb9bhWh1IwBZ1ZoS60.jpg\",alt:\"Sticker 3\",size:64,decay:1200}],style}=props;const[stickers,setStickers]=useState([]);const containerRef=useRef(null);const nextId=useRef(0);// Throttle sticker placement\nconst lastPlacedRef=useRef(0);const STICKER_DELAY=60// ms\n;// Sequential sticker index\nconst stickerIndex=useRef(0);function handleMouseMove(e){if(RenderTarget.current()!==RenderTarget.preview)return;if(!images.length)return;const now=Date.now();if(now-lastPlacedRef.current<STICKER_DELAY)return;lastPlacedRef.current=now;const rect=containerRef.current?.getBoundingClientRect();if(!rect)return;const x=e.clientX-rect.left;const y=e.clientY-rect.top;const idx=stickerIndex.current%images.length;const img=images[idx];stickerIndex.current++;const size=typeof img.size===\"number\"?img.size:64;const id=nextId.current++;const created=Date.now();startTransition(()=>setStickers(prev=>[...prev,{src:img.src,alt:img.alt,x,y,size,created,id}]));}// Fade out and remove stickers after global decay\nuseEffect(()=>{if(!stickers.length)return;if(!props.decayEnabled)return;const interval=setInterval(()=>{const now=Date.now();startTransition(()=>setStickers(prev=>prev.filter(s=>now-s.created<(props.decay||1200))));},50);return()=>clearInterval(interval);},[stickers.length,props.decay,props.decayEnabled]);const now=Date.now();return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:{...style,width:\"100%\",height:\"100%\",position:\"relative\",overflow:\"visible\",cursor:\"crosshair\",background:\"transparent\"},onMouseMove:handleMouseMove,\"aria-label\":\"Sticker background\",children:stickers.map(sticker=>{let fade=1;if(props.decayEnabled){const elapsed=now-sticker.created;fade=Math.max(0,Math.min(1,1+.2-elapsed/(props.decay||1200)));}return /*#__PURE__*/_jsx(\"img\",{src:sticker.src,alt:sticker.alt,style:{position:\"absolute\",left:sticker.x-sticker.size/2,top:sticker.y-sticker.size/2,width:sticker.size,height:sticker.size,objectFit:\"contain\",pointerEvents:\"none\",userSelect:\"none\",opacity:fade,transition:\"opacity 0.2s linear\"},draggable:false},sticker.id);})});}addPropertyControls(MouseStickerBackground,{images:{type:ControlType.Array,title:\"Stickers\",control:{type:ControlType.Object,controls:{src:{type:ControlType.File,title:\"Sticker Image\",allowedFileTypes:[\"jpg\",\"jpeg\",\"png\",\"gif\",\"webp\",\"svg\"]},alt:{type:ControlType.String,title:\"Alt Text\",defaultValue:\"Sticker\"},size:{type:ControlType.Number,title:\"Size\",defaultValue:64,min:16,max:256,unit:\"px\"}}},defaultValue:[{src:\"https://framerusercontent.com/images/GfGkADagM4KEibNcIiRUWlfrR0.jpg\",alt:\"Sticker 1\",size:64},{src:\"https://framerusercontent.com/images/aNsAT3jCvt4zglbWCUoFe33Q.jpg\",alt:\"Sticker 2\",size:64},{src:\"https://framerusercontent.com/images/BYnxEV1zjYb9bhWh1IwBZ1ZoS60.jpg\",alt:\"Sticker 3\",size:64}],maxCount:10},decayEnabled:{type:ControlType.Boolean,title:\"Fade Stickers\",defaultValue:true,enabledTitle:\"On\",disabledTitle:\"Off\"},decay:{type:ControlType.Number,title:\"Fade Duration\",defaultValue:1200,min:200,max:5e3,unit:\"ms\",hidden:({decayEnabled})=>!decayEnabled}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"MouseStickerBackground\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./MouseStickerBackground.map"],"mappings":"sMAMG,SAAwB,EAAuB,EAAM,CAAC,GAAK,CAAC,SAAO,CAAC,CAAC,IAAI,sEAAsE,IAAI,YAAY,KAAK,GAAG,MAAM,KAAK,CAAC,CAAC,IAAI,oEAAoE,IAAI,YAAY,KAAK,GAAG,MAAM,KAAK,CAAC,CAAC,IAAI,uEAAuE,IAAI,YAAY,KAAK,GAAG,MAAM,KAAK,CAAC,CAAC,SAAO,EAAW,CAAC,EAAS,GAAaA,EAAS,EAAE,CAAC,CAAO,EAAaC,EAAO,KAAK,CAAO,EAAOA,EAAO,EAAE,CAC1f,EAAcA,EAAO,EAAE,CAEvB,EAAaA,EAAO,EAAE,CAAC,SAAS,EAAgB,EAAE,CAAyD,GAArD,EAAa,SAAS,GAAG,EAAa,SAAkB,CAAC,EAAO,OAAO,OAAO,IAAMC,EAAI,KAAK,KAAK,CAAC,GAAGA,EAAI,EAAc,QAAQ,GAAc,OAAO,EAAc,QAAQA,EAAI,IAAM,EAAK,EAAa,SAAS,uBAAuB,CAAC,GAAG,CAAC,EAAK,OAAO,IAAM,EAAE,EAAE,QAAQ,EAAK,KAAW,EAAE,EAAE,QAAQ,EAAK,IAAuD,EAAI,EAA7C,EAAa,QAAQ,EAAO,QAA6B,EAAa,UAAU,IAAM,EAAK,OAAO,EAAI,MAAO,SAAS,EAAI,KAAK,GAAS,EAAG,EAAO,UAAgB,EAAQ,KAAK,KAAK,CAAC,MAAoB,EAAY,GAAM,CAAC,GAAG,EAAK,CAAC,IAAI,EAAI,IAAI,IAAI,EAAI,IAA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