{"version":3,"file":"HeroTextScroll.DC3tuEfP.mjs","names":["useRef","__esmMin","window","init_npm_react_18_3_1","init_ssg_sandbox_shims","de","init_jsx_runtime","J","ce","RenderTarget","init_framer_BisrWwwE","findHero","ancestors","node","el","withImage","child","fraction","minHeight","tall","untranslatedBounds","applied","parts","top","bottom","part","rect","scrollY","withHeroTextScroll","probe","frame","hero","register","next","heroMembers","\"delete\"","update","heroBottom","member","bounds","end","drift","i","clamp","MAX_PARALLAX","leavesTopAt","progress","onScroll","onResize","Component","props","init_HeroTextScroll","value","min","max"],"sources":["https:/framerusercontent.com/modules/5vmQNem7uU9ruvD0aGMp/egFBVXI2Kp4WRgYqzCxd/HeroTextScroll.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{forwardRef,useEffect,useRef}from\"react\";import{RenderTarget}from\"framer\";// Upper limit on parallax drift: the homepage uses Framer parallax speed 40%,\n// which moves text at 60% of scroll.\nconst MAX_PARALLAX=.6;// Every text element using this override, grouped by the hero it sits in, so all\n// text in one hero drifts and fades together.\nconst heroMembers=new Map;// The hero is the nearest ancestor that renders an image fill; otherwise the nearest\n// ancestor at least 70% (then 50%) of the viewport tall.\nfunction findHero(el){const ancestors=[];for(let node=el.parentElement;node&&node!==document.body;node=node.parentElement)ancestors.push(node);const withImage=ancestors.find(node=>Array.from(node.children).some(child=>child.hasAttribute(\"data-framer-background-image-wrapper\")));if(withImage)return withImage;for(const fraction of[.7,.5]){const minHeight=window.innerHeight*fraction;const tall=ancestors.find(node=>node.getBoundingClientRect().height>=minHeight);if(tall)return tall;}return el;}// Page-coordinate top/bottom of an element's visible content, ignoring the translate we\n// applied. Measures the element's children when it has any, so a container stretched\n// to fill the hero is measured by its text rather than its full box.\nfunction untranslatedBounds(el,scrollY){const applied=parseFloat((el.style.translate||\"\").split(\" \")[1]||\"0\")||0;const parts=el.children.length?Array.from(el.children):[el];let top=Infinity;let bottom=-Infinity;for(const part of parts){const rect=part.getBoundingClientRect();if(rect.width===0&&rect.height===0)continue;// hidden on this breakpoint\ntop=Math.min(top,rect.top);bottom=Math.max(bottom,rect.bottom);}if(!Number.isFinite(top))return null;return{top:top+scrollY-applied,bottom:bottom+scrollY-applied};}const clamp=(value,min,max)=>Math.min(Math.max(value,min),max);// Parallax + fade-out on scroll for hero text. The fade runs the full length of the\n// hero, ending as the hero's bottom edge leaves the viewport, or sooner if the text\n// would otherwise scroll off the top first. The drift is sized per hero so the text's\n// bottom edge meets the bottom of the hero image exactly as it finishes fading, so it\n// never slides past the image. Uses CSS translate so it composes with Framer's own\n// transforms, and writes styles directly to avoid re-renders.\nexport function withHeroTextScroll(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const probe=useRef(null);useEffect(()=>{if(RenderTarget.current()===RenderTarget.canvas)return;let frame=0;let el=null;let hero=null;const register=()=>{const next=probe.current?.firstElementChild;if(!next)return;if(hero&&el)heroMembers.get(hero)?.[\"delete\"](el);el=next;hero=findHero(el);if(!heroMembers.has(hero))heroMembers.set(hero,new Set);heroMembers.get(hero).add(el);};const update=()=>{frame=0;if(!el||!hero||!el.isConnected||!hero.isConnected)register();if(!el||!hero)return;const scrollY=Math.max(window.scrollY,0);const heroBottom=hero.getBoundingClientRect().bottom+scrollY;let top=Infinity;let bottom=-Infinity;for(const member of heroMembers.get(hero)??[]){if(!member.isConnected)continue;const bounds=untranslatedBounds(member,scrollY);if(!bounds)continue;top=Math.min(top,bounds.top);bottom=Math.max(bottom,bounds.bottom);}if(!Number.isFinite(top))return;let end=Math.max(heroBottom,1);let drift=0;for(let i=0;i<4;i++){drift=clamp((heroBottom-bottom)/end,0,MAX_PARALLAX);const leavesTopAt=top/(1-drift);if(leavesTopAt>=end)break;end=Math.max(leavesTopAt,1);}drift=clamp((heroBottom-bottom)/end,0,MAX_PARALLAX);const progress=Math.min(scrollY,end);el.style.translate=`0px ${(progress*drift).toFixed(1)}px`;el.style.opacity=String(1-progress/end);};const onScroll=()=>{if(!frame)frame=requestAnimationFrame(update);};const onResize=()=>{register();onScroll();};register();update();window.addEventListener(\"scroll\",onScroll,{passive:true});window.addEventListener(\"resize\",onResize);return()=>{window.removeEventListener(\"scroll\",onScroll);window.removeEventListener(\"resize\",onResize);if(frame)cancelAnimationFrame(frame);if(hero&&el)heroMembers.get(hero)?.[\"delete\"](el);};},[]);return /*#__PURE__*/_jsx(\"div\",{ref:probe,style:{display:\"contents\"},children:/*#__PURE__*/_jsx(Component,{...props,ref:ref})});});}\nexport const __FramerMetadata__ = {\"exports\":{\"withHeroTextScroll\":{\"type\":\"reactHoc\",\"name\":\"withHeroTextScroll\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./HeroTextScroll.map"],"mappings":"A,2LAMA,SAASW,EAAS,EAAG,CAAC,IAAMC,EAAU,CAAC,EAAE,IAAI,IAAIC,EAAKC,EAAG,cAAcD,GAAMA,IAAO,SAAS,KAAK,EAAKA,EAAK,cAAcD,EAAU,KAAKC,CAAI,EAAE,IAAME,EAAUH,EAAU,KAAK,GAAM,MAAM,KAAKC,EAAK,QAAQ,CAAC,CAAC,KAAK,GAAOG,EAAM,aAAa,sCAAsC,CAAC,CAAC,EAAE,GAAGD,EAAU,OAAOA,EAAU,IAAI,IAAME,IAAW,CAAC,GAAG,EAAE,EAAE,CAAC,IAAMC,EAAUhB,EAAO,YAAYe,EAAeE,EAAKP,EAAU,KAAK,GAAMC,EAAK,sBAAsB,CAAC,CAAC,QAAQK,CAAS,EAAE,GAAGC,EAAK,OAAOA,CAAK,CAAC,OAAOL,CAAG,CAG9e,SAASM,EAAmB,EAAG,EAAQ,CAAC,IAAMC,EAAQ,YAAYP,EAAG,MAAM,WAAW,GAAA,CAAI,MAAM,GAAG,CAAC,CAAC,IAAI,GAAG,GAAG,EAAQQ,EAAMR,EAAG,SAAS,OAAO,MAAM,KAAKA,EAAG,QAAQ,EAAE,CAACA,CAAE,EAAMS,EAAI,IAAaC,EAAO,KAAU,IAAI,IAA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