{"version":3,"file":"FocusImage.xMDIB6zc.mjs","names":["useRef"],"sources":["https:/framerusercontent.com/modules/lHtvfEwXVOD1Mysja7XR/6rf7DX8zxj0CWkWeuZp3/FocusImage.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";import{useEffect,useRef}from\"react\";const clamp=(v,a,b)=>Math.min(b,Math.max(a,v));const SHEET=`\n.fi{position:relative;width:100%;height:100%;overflow:hidden;container-type:inline-size;isolation:isolate}\n.fi-in{position:absolute;left:0;right:0;top:calc(var(--drift) * -1%);bottom:calc(var(--drift) * -1%);transform:translate3d(0,calc(var(--y) * 1px),0) scale(var(--s));will-change:transform}\n.fi-in img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;display:block;user-select:none;-webkit-user-drag:none}\n.fi-b{filter:blur(max(12px,3cqw));transform:scale(1.1);opacity:var(--bo)}\n.fi-s{opacity:var(--k)}\n`;/**\n * Focus Image\n *\n * A photograph that drifts a little as the page scrolls and comes into\n * focus as it arrives. Works on any photo.\n *\n * @framerIntrinsicWidth 480\n * @framerIntrinsicHeight 600\n *\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight fixed\n */export default function FocusImage(props){const{image={src:\"https://framerusercontent.com/images/GfGkADagM4KEibNcIiRUWlfrR0.jpg\",alt:\"\"},altText=\"\",drift=8,imageWidth=\"40vw\",cornerRadius=2}=props;const isStatic=useIsStaticRenderer();const root=useRef(null);useEffect(()=>{const host=root.current;if(!host||isStatic)return;if(window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches)return;let raf=0;let last=0;let goalK=1;let goalY=0;let k=-1;let y=0;const read=()=>{const r=host.getBoundingClientRect();const vh=window.innerHeight;// 0 when the top edge reaches the bottom of the window, 1 when\n// the bottom edge leaves through the top.\nconst t=clamp((vh-r.top)/(vh+r.height),0,1);const f=clamp((t-.1)/.32,0,1);goalK=f*f*(3-2*f);goalY=(.5-t)*2*(r.height*drift/100);};const paint=()=>{host.style.setProperty(\"--k\",k.toFixed(3));host.style.setProperty(\"--bo\",(1-Math.pow(k,4)).toFixed(3));host.style.setProperty(\"--s\",(1.08-.08*k).toFixed(4));host.style.setProperty(\"--y\",y.toFixed(2));};const tick=time=>{raf=0;const dt=Math.min(64,Math.max(1,time-last));last=time;const a=1-Math.exp(-dt/130);if(k<0){k=goalK;y=goalY;}else{k+=(goalK-k)*a;y+=(goalY-y)*a;}if(Math.abs(goalK-k)<.002)k=goalK;if(Math.abs(goalY-y)<.2)y=goalY;paint();if(k!==goalK||y!==goalY)raf=requestAnimationFrame(tick);};const wake=()=>{read();if(!raf){last=performance.now();raf=requestAnimationFrame(tick);}};wake();window.addEventListener(\"scroll\",wake,{passive:true});window.addEventListener(\"resize\",wake);return()=>{window.removeEventListener(\"scroll\",wake);window.removeEventListener(\"resize\",wake);if(raf)cancelAnimationFrame(raf);};},[isStatic,drift]);const vars={\"--drift\":String(drift),\"--k\":\"1\",\"--bo\":\"0\",\"--s\":\"1\",\"--y\":\"0\"};const alt=altText||image.alt||\"\";return /*#__PURE__*/_jsxs(\"div\",{ref:root,className:\"fi\",style:{...props.style,...vars,borderRadius:cornerRadius},children:[/*#__PURE__*/_jsx(\"style\",{dangerouslySetInnerHTML:{__html:SHEET}}),/*#__PURE__*/_jsxs(\"div\",{className:\"fi-in\",children:[/*#__PURE__*/_jsx(\"img\",{className:\"fi-b\",srcSet:image.srcSet,sizes:imageWidth,src:image.src,alt:\"\",loading:\"lazy\",decoding:\"async\",draggable:false}),/*#__PURE__*/_jsx(\"img\",{className:\"fi-s\",srcSet:image.srcSet,sizes:imageWidth,src:image.src,alt:alt,loading:\"lazy\",decoding:\"async\",draggable:false})]})]});}addPropertyControls(FocusImage,{image:{type:ControlType.ResponsiveImage,title:\"Photo\"},altText:{type:ControlType.String,title:\"Alt text\",defaultValue:\"\",description:\"Describes the photo for screen readers. Leave empty to use the photo's own description.\"},drift:{type:ControlType.Number,title:\"Drift\",defaultValue:8,min:0,max:20,step:1,unit:\"%\",description:\"How far the photo moves inside its frame while the page scrolls. 0 keeps it still.\"},imageWidth:{type:ControlType.String,title:\"Image width\",defaultValue:\"40vw\",description:\"How wide the photo is on screen, for example 40vw. Used to load the right image size.\"},cornerRadius:{type:ControlType.Number,title:\"Radius\",defaultValue:2,min:0,max:40,step:1,unit:\"px\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"FocusImage\",\"slots\":[],\"annotations\":{\"framerIntrinsicWidth\":\"480\",\"framerSupportedLayoutHeight\":\"fixed\",\"framerSupportedLayoutWidth\":\"fixed\",\"framerContractVersion\":\"1\",\"framerIntrinsicHeight\":\"600\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./FocusImage.map"],"mappings":"8MAiBG,SAAwB,EAAW,EAAM,CAAC,GAAK,CAAC,QAAM,CAAC,IAAI,sEAAsE,IAAI,EAAE,EAAE,UAAQ,GAAG,QAAM,EAAE,aAAW,OAAO,eAAa,GAAG,EAAY,EAAS,EAAoB,EAAQ,EAAKA,EAAO,IAAI,EAAE,MAAc,CAAC,IAAM,EAAK,EAAK,QAAkC,GAAvB,CAAC,GAAM,GAAmB,EAAO,WAAW,kCAAkC,CAAC,CAAC,QAAQ,OAAO,IAAI,EAAI,EAAM,EAAK,EAAM,EAAM,EAAM,EAAM,EAAM,EAAE,GAAO,EAAE,EAAQ,MAAS,CAAC,IAAM,EAAE,EAAK,sBAAsB,EAAQ,EAAG,EAAO,YAE1gB,EAAE,GAAO,EAAG,EAAE,MAAM,EAAG,EAAE,QAAQ,EAAE,CAAC,EAAQ,EAAE,GAAO,EAAE,IAAI,IAAI,EAAE,CAAC,EAAE,EAAM,EAAE,GAAG,EAAE,EAAE,GAAG,GAAO,GAAG,GAAG,GAAG,EAAE,OAAO,EAAM,IAAK,EAAQ,MAAU,CAAC,EAAK,MAAM,YAAY,MAAM,EAAE,QAAQ,CA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