{"version":3,"file":"MouseStickerBackground.DzOhW_IK.mjs","names":["useState","useRef"],"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,IAAI,EAAE,CAAC,IAAI,oEAAoE,IAAI,YAAY,KAAK,GAAG,MAAM,IAAI,EAAE,CAAC,IAAI,uEAAuE,IAAI,YAAY,KAAK,GAAG,MAAM,IAAI,CAAC,EAAE,SAAO,EAAW,CAAC,EAAS,GAAaA,EAAS,CAAC,CAAC,EAAQ,EAAaC,EAAO,IAAI,EAAQ,EAAOA,EAAO,CAAC,EACzf,EAAcA,EAAO,CAAC,EAEtB,EAAaA,EAAO,CAAC,EAAE,SAAS,EAAgB,EAAE,CAAyD,GAArD,EAAa,QAAQ,IAAI,EAAa,SAAkB,CAAC,EAAO,OAAO,OAAO,IAAM,EAAI,KAAK,IAAI,EAAE,GAAG,EAAI,EAAc,QAAQ,GAAc,OAAO,EAAc,QAAQ,EAAI,IAAM,EAAK,EAAa,SAAS,sBAAsB,EAAE,GAAG,CAAC,EAAK,OAAO,IAAM,EAAE,EAAE,QAAQ,EAAK,KAAW,EAAE,EAAE,QAAQ,EAAK,IAAU,EAAI,EAAa,QAAQ,EAAO,OAAa,EAAI,EAAO,GAAK,EAAa,UAAU,IAAM,EAAK,OAAO,EAAI,MAAO,SAAS,EAAI,KAAK,GAAS,EAAG,EAAO,UAAgB,EAAQ,KAAK,IAAI,EAAE,MAAoB,EAAY,GAAM,CAAC,GAAG,EAAK,CAAC,IAAI,EAAI,IAAI,IAAI,EAA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