{"version":3,"file":"FloatingImage.BVIRzHdX.mjs","names":["useRef"],"sources":["https:/framerusercontent.com/modules/Yg6hmTqXPNnCCjVI6AA3/Q3SKGiQ7f05MbsgsU2Eo/FloatingImage.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";import{useEffect,useRef}from\"react\";/** Travel budget at depth 1, in px. */const MAX_SHIFT=600;/**\n * Floating Image\n *\n * A fully-visible image (not cropped like a full-bleed background) that\n * drifts against its container as the container travels across the\n * viewport. Reads its own on-screen position every frame rather than\n * listening for scroll, so it also works inside transform-driven tracks\n * (such as a horizontal scroller) where scroll-linked effects never fire.\n *\n * Set `axis` to match the direction the container actually travels.\n * `depth`'s sign flips the drift direction; its magnitude sets how far it\n * travels.\n *\n * @framerIntrinsicWidth 400\n * @framerIntrinsicHeight 600\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function FloatingImage(props){const{image={src:\"https://framerusercontent.com/images/GfGkADagM4KEibNcIiRUWlfrR0.jpg\",alt:\"\"},axis=\"horizontal\",depth=.35,imageOpacity=1,style}=props;const isStatic=useIsStaticRenderer();const rootRef=useRef(null);const layerRef=useRef(null);const rafRef=useRef(null);const clampedDepth=Math.max(-1,Math.min(1,depth));const isHorizontal=axis!==\"vertical\";useEffect(()=>{if(isStatic||typeof window===\"undefined\")return;const root=rootRef.current;const layer=layerRef.current;if(!root||!layer)return;let running=false;let lastOffset=NaN;const apply=()=>{const rect=root.getBoundingClientRect();const viewport=isHorizontal?window.innerWidth:window.innerHeight;if(viewport===0)return;const size=isHorizontal?rect.width:rect.height;const start=isHorizontal?rect.left:rect.top;const fromCenter=start+size/2-viewport/2;const span=(viewport+size)/2;let t=span>0?fromCenter/span:0;if(t>1)t=1;if(t<-1)t=-1;const offset=-t*clampedDepth*MAX_SHIFT;if(offset!==lastOffset){layer.style.transform=isHorizontal?`translate3d(${offset}px, 0, 0)`:`translate3d(0, ${offset}px, 0)`;lastOffset=offset;}};const tick=()=>{apply();if(running)rafRef.current=window.requestAnimationFrame(tick);};const start=()=>{if(running)return;running=true;rafRef.current=window.requestAnimationFrame(tick);};const stop=()=>{running=false;if(rafRef.current!==null){window.cancelAnimationFrame(rafRef.current);rafRef.current=null;}};apply();let observer=null;if(typeof IntersectionObserver!==\"undefined\"){observer=new IntersectionObserver(entries=>{for(const entry of entries){if(entry.isIntersecting)start();else stop();}},{rootMargin:\"200px\"});observer.observe(root);}else{start();}window.addEventListener(\"resize\",apply);return()=>{stop();if(observer)observer.disconnect();window.removeEventListener(\"resize\",apply);};},[isStatic,isHorizontal,clampedDepth]);const label=image?.alt??\"\";return /*#__PURE__*/_jsx(\"div\",{ref:rootRef,style:{...style,position:\"relative\",width:style?.width??\"100%\",height:style?.height??\"100%\"},children:/*#__PURE__*/_jsx(\"div\",{ref:layerRef,role:label?\"img\":undefined,\"aria-label\":label||undefined,\"aria-hidden\":label?undefined:true,style:{position:\"absolute\",inset:0,backgroundImage:image?.src?`url(\"${image.src}\")`:undefined,backgroundSize:\"contain\",backgroundPosition:\"center\",backgroundRepeat:\"no-repeat\",opacity:imageOpacity,willChange:\"transform\"}})});}addPropertyControls(FloatingImage,{image:{type:ControlType.ResponsiveImage,title:\"Image\"},axis:{type:ControlType.Enum,title:\"Axis\",defaultValue:\"horizontal\",options:[\"horizontal\",\"vertical\"],optionTitles:[\"Horizontal\",\"Vertical\"],displaySegmentedControl:true},depth:{type:ControlType.Number,title:\"Depth\",defaultValue:.35,min:-1,max:1,step:.05},imageOpacity:{type:ControlType.Number,title:\"Image Opacity\",defaultValue:1,min:0,max:1,step:.05}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"FloatingImage\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framer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