{"version":3,"file":"Scroll_effect.DsG9hSe9.mjs","names":["useState","useRef"],"sources":["https:/framerusercontent.com/modules/DsHt1ILtwAIQsUPpZARk/h2rDUgVmAh8Oq2h3wpdV/Scroll_effect.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useRef,useState}from\"react\";import{useScroll,useMotionValue,useMotionValueEvent}from\"framer-motion\";// Animation completes at this fraction of the scroll range.\n// The remainder acts as a pause on the last card.\n// 0.85 = finish at 85%, hold for the final 15%.\nconst COMPLETE_AT=.85;// ---------------------------------------------\n// Shared: measures scroll range from step-1 to step-4\n// ---------------------------------------------\nfunction useStepRange(){const[range,setRange]=useState([0,1]);useEffect(()=>{const measure=()=>{const first=document.querySelector(\"#step-1\");const last=document.querySelector(\"#step-4\");if(!first||!last){console.log(\"step range: missing\",{first,last});return;}const scrollTop=window.scrollY;setRange([first.getBoundingClientRect().top+scrollTop,last.getBoundingClientRect().bottom+scrollTop-window.innerHeight]);};measure();window.addEventListener(\"resize\",measure);return()=>window.removeEventListener(\"resize\",measure);},[]);return range;}// progress 0..1 across the range, finishing early per COMPLETE_AT\nfunction scrubProgress(y,start,end){const raw=(y-start)/(end-start);return Math.min(Math.max(raw/COMPLETE_AT,0),1);}// ---------------------------------------------\n// Van — apply to the Van layer.\n// Travel distance measured against #cards-viewport.\n// ---------------------------------------------\nexport function withVanScrub(Component){return props=>{const vanRef=useRef(null);const{scrollY}=useScroll();const range=useStepRange();const x=useMotionValue(0);const dist=useRef(0);const rangeRef=useRef(range);rangeRef.current=range;useEffect(()=>{const measure=()=>{const van=vanRef.current;const viewport=document.querySelector(\"#cards-viewport\");if(!van||!viewport)return;dist.current=Math.max(viewport.getBoundingClientRect().width-van.getBoundingClientRect().width,0);};const t=setTimeout(measure,100);window.addEventListener(\"resize\",measure);return()=>{clearTimeout(t);window.removeEventListener(\"resize\",measure);};},[]);useMotionValueEvent(scrollY,\"change\",y=>{const[start,end]=rangeRef.current;x.set(-scrubProgress(y,start,end)*dist.current);});return /*#__PURE__*/_jsx(Component,{...props,ref:vanRef,style:{...props.style,x}});};}// ---------------------------------------------\n// Cards — apply to the Tabs stack (holds the cards).\n// Education Slider Sticky: Scroll Section name = cards-viewport,\n// Width = Fill, Overflow = Visible.\n// Tabs: horizontal stack, hugs its fixed-width cards.\n// Sideways input steers vertical scroll, so both\n// directions drive the same animation.\n// ---------------------------------------------\nexport function withCardsScrub(Component){return props=>{const ref=useRef(null);const{scrollY}=useScroll();const range=useStepRange();const x=useMotionValue(0);const dist=useRef(0);const rangeRef=useRef(range);rangeRef.current=range;// travel distance: content width minus viewport width\nuseEffect(()=>{const measure=()=>{const el=ref.current;const viewport=document.querySelector(\"#cards-viewport\");if(!el||!viewport)return;let contentWidth=Math.max(el.getBoundingClientRect().width,el.scrollWidth);for(const child of Array.from(el.children)){contentWidth=Math.max(contentWidth,child.scrollWidth,child.getBoundingClientRect().width);}dist.current=Math.max(contentWidth-viewport.getBoundingClientRect().width,0);};const t=setTimeout(measure,100);window.addEventListener(\"resize\",measure);return()=>{clearTimeout(t);window.removeEventListener(\"resize\",measure);};},[]);// vertical page scroll is the single source of truth\nuseMotionValueEvent(scrollY,\"change\",y=>{const[start,end]=rangeRef.current;x.set(-scrubProgress(y,start,end)*dist.current);});// sideways input steers the page's vertical scroll,\n// so cards, van and steps all stay in sync\nconst sidewaysToVertical=deltaX=>{const[start,end]=rangeRef.current;if(dist.current===0)return;const factor=(end-start)*COMPLETE_AT/dist.current;window.scrollBy(0,deltaX*factor);};useEffect(()=>{const el=ref.current;if(!el)return;const onWheel=e=>{if(Math.abs(e.deltaX)<=Math.abs(e.deltaY))return;e.preventDefault();sidewaysToVertical(e.deltaX);};el.addEventListener(\"wheel\",onWheel,{passive:false});return()=>el.removeEventListener(\"wheel\",onWheel);},[]);// touch: horizontal drag steers vertical scroll too\nuseEffect(()=>{const el=ref.current;if(!el)return;let lastX=0;let active=false;const down=e=>{lastX=e.touches[0].clientX;active=true;};const move=e=>{if(!active)return;const cur=e.touches[0].clientX;const deltaX=lastX-cur;lastX=cur;if(Math.abs(deltaX)>0)sidewaysToVertical(deltaX);};const up=()=>active=false;el.addEventListener(\"touchstart\",down,{passive:true});el.addEventListener(\"touchmove\",move,{passive:true});el.addEventListener(\"touchend\",up);return()=>{el.removeEventListener(\"touchstart\",down);el.removeEventListener(\"touchmove\",move);el.removeEventListener(\"touchend\",up);};},[]);return /*#__PURE__*/_jsx(Component,{...props,ref:ref,style:{...props.style,x}});};}\nexport const __FramerMetadata__ = {\"exports\":{\"withCardsScrub\":{\"type\":\"reactHoc\",\"name\":\"withCardsScrub\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withVanScrub\":{\"type\":\"reactHoc\",\"name\":\"withVanScrub\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Scroll_effect.map"],"mappings":"6MAMA,SAAS,GAAc,CAAC,GAAK,CAAC,EAAM,GAAUA,EAAS,CAAC,EAAE,CAAC,CAAC,EAAod,OAAld,MAAc,CAAC,IAAM,MAAY,CAAC,IAAM,EAAM,SAAS,cAAc,SAAS,EAAQ,EAAK,SAAS,cAAc,SAAS,EAAE,GAAG,CAAC,GAAO,CAAC,EAAK,CAAC,QAAQ,IAAI,sBAAsB,CAAC,QAAM,MAAI,CAAC,EAAE,MAAO,CAAC,IAAM,EAAU,EAAO,QAAQ,EAAS,CAAC,EAAM,sBAAsB,CAAC,CAAC,IAAI,EAAU,EAAK,sBAAsB,CAAC,CAAC,OAAO,EAAU,EAAO,WAAW,CAAC,CAAE,EAAsD,OAApD,EAAQ,EAAE,EAAO,iBAAiB,SAAS,CAAO,MAAY,EAAO,oBAAoB,SAAS,CAAO,CAAE,EAAE,CAAC,CAAC,EAAS,CAAM,CAC7hB,SAAS,EAAc,EAAE,EAAM,EAAI,CAAC,IAAM,GAAK,EAAE,IAAQ,EAAI,GAAO,OAAO,KAAK,IAAI,KAAK,IAAI,EA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