{"version":3,"file":"BouncingImage.CiUpWPMd.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/8qqoLb3GO7MAZriRltK4/XPS1ywBQfrhVJBNFtvy1/BouncingImage.js"],"sourcesContent":["// DVD-style bouncing image animation with customizable image, speed, and border radius. Image is 1:1 (default 60px). Container adapts to parent.\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useRef,useEffect,useState,startTransition}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";const defaultImage={src:\"https://framerusercontent.com/images/GfGkADagM4KEibNcIiRUWlfrR0.jpg\",alt:\"Gradient 1 - Blue\"};/**\n * DVD Bouncing Image\n *\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n */export default function BouncingImage(props){const{image=defaultImage,speed,radius,size,shadow,style}=props;const containerRef=useRef(null);const[pos,setPos]=useState({x:0,y:0});const[dir,setDir]=useState({x:1,y:1});const[container,setContainer]=useState({width:300,height:200});const isStatic=useIsStaticRenderer();// Update container size on mount and resize\nuseEffect(()=>{function updateSize(){if(containerRef.current){const rect=containerRef.current.getBoundingClientRect();startTransition(()=>setContainer({width:rect.width,height:rect.height}));}}updateSize();window.addEventListener(\"resize\",updateSize);return()=>window.removeEventListener(\"resize\",updateSize);},[]);// Animation loop\nuseEffect(()=>{if(isStatic)return;let frame;function animate(){setPos(prev=>{let{x,y}=prev;let{x:dx,y:dy}=dir;const maxX=container.width-size;const maxY=container.height-size;x+=dx*speed;y+=dy*speed;let newDir={...dir};if(x<=0){x=0;newDir.x=1;}if(x>=maxX){x=maxX;newDir.x=-1;}if(y<=0){y=0;newDir.y=1;}if(y>=maxY){y=maxY;newDir.y=-1;}if(newDir.x!==dir.x||newDir.y!==dir.y)startTransition(()=>setDir(newDir));return{x,y};});frame=requestAnimationFrame(animate);}frame=requestAnimationFrame(animate);return()=>cancelAnimationFrame(frame);},[container.width,container.height,dir,speed,size,isStatic]);// Reset position if container or size changes\nuseEffect(()=>{startTransition(()=>setPos({x:0,y:0}));startTransition(()=>setDir({x:1,y:1}));},[container.width,container.height,size]);// Static preview: center image\nif(isStatic){return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:{...style,width:\"100%\",height:\"100%\",position:\"relative\",overflow:\"hidden\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\"},children:/*#__PURE__*/_jsx(\"img\",{src:image.src,alt:image.alt,style:{width:size,height:size,borderRadius:radius,objectFit:\"contain\",background:\"transparent\",pointerEvents:\"none\",userSelect:\"none\",boxShadow:shadow}})});}return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:{...style,width:\"100%\",height:\"100%\",position:\"relative\",overflow:\"hidden\"},children:/*#__PURE__*/_jsx(\"img\",{src:image.src,alt:image.alt,style:{width:size,height:size,borderRadius:radius,objectFit:\"contain\",background:\"transparent\",position:\"absolute\",left:pos.x,top:pos.y,pointerEvents:\"none\",userSelect:\"none\",boxShadow:shadow,transition:isStatic?\"left 0.2s, top 0.2s\":undefined},draggable:false})});}addPropertyControls(BouncingImage,{image:{type:ControlType.ResponsiveImage,title:\"Image\"},speed:{type:ControlType.Number,title:\"Speed\",defaultValue:2,min:.5,max:10,step:.1},radius:{type:ControlType.Number,title:\"Radius\",defaultValue:16,min:0,max:60,step:1,unit:\"px\"},size:{type:ControlType.Number,title:\"Image Size\",defaultValue:60,min:20,max:300,step:1,unit:\"px\"},shadow:{type:ControlType.BoxShadow,title:\"Shadow\",defaultValue:\"0 2px 8px rgba(0,0,0,0.08)\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"BouncingImage\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"any\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./BouncingImage.map"],"mappings":"qNAMG,SAAwB,EAAc,EAAM,CAAC,GAAK,CAAC,QAAM,EAAa,QAAM,SAAO,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