{"version":3,"file":"Examples.Cvbwip4B.mjs","names":["useRef","useState","p"],"sources":["https:/framerusercontent.com/modules/FZOR9yosW7LV2W9r2Ib4/72LGkrxozKqg8hb2xPMJ/Examples.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useRef,useState,useEffect}from\"react\";import{useScroll,useSpring,useInView}from\"framer-motion\";export function withScrolledProgressInView(Component){return props=>{const ref=useRef(null);const isInView=useInView(ref,{amount:.01})// only true when 20% in view\n;const[maxProgress,setMaxProgress]=useState(3);const[isPlaying,setIsPlaying]=useState(false);const{scrollYProgress}=useScroll({target:ref,offset:[\"end\",\"start\"],layoutEffect:false});const animationProgress=useSpring(scrollYProgress,{stiffness:20,damping:20});useEffect(()=>{if(!isInView)return;const unsubscribe=scrollYProgress.on(\"change\",p=>{if(!isPlaying){if(p>maxProgress){setMaxProgress(p);}if(p>.05){setIsPlaying(true);}}});return()=>unsubscribe();},[scrollYProgress,maxProgress,isPlaying,isInView]);useEffect(()=>{if(isPlaying&&maxProgress<1){const interval=setInterval(()=>{setMaxProgress(prev=>{if(prev>=1){clearInterval(interval);return 1;}return prev+.02;});},16);return()=>clearInterval(interval);}},[isPlaying]);return /*#__PURE__*/_jsx(\"div\",{ref:ref,style:props.style,children:isInView&&/*#__PURE__*/_jsx(Component,{...props,progress:maxProgress})});};}\nexport const __FramerMetadata__ = {\"exports\":{\"withScrolledProgressInView\":{\"type\":\"reactHoc\",\"name\":\"withScrolledProgressInView\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Examples.map"],"mappings":"4RAAiJ,SAAgB,EAA2B,EAAU,CAAC,MAAO,IAAO,CAAC,IAAM,EAAIA,EAAO,KAAK,CAAO,EAAS,EAAU,EAAI,CAAC,OAAO,IAAI,CAAC,CACjR,CAAC,EAAY,GAAgBC,EAAS,EAAE,CAAM,CAAC,EAAU,GAAcA,EAAS,GAAM,CAAM,CAAC,mBAAiB,EAAU,CAAC,OAAO,EAAI,OAAO,CAAC,MAAM,QAAQ,CAAC,aAAa,GAAM,CAAC,CAAgiB,OAAvgB,EAAU,EAAgB,CAAC,UAAU,GAAG,QAAQ,GAAG,CAAC,CAAC,MAAc,CAAC,GAAG,CAAC,EAAS,OAAO,IAAM,EAAY,EAAgB,GAAG,SAAS,GAAG,CAAK,IAAcC,EAAE,GAAa,EAAeA,EAAE,CAAKA,EAAE,KAAK,EAAa,GAAK,GAAK,CAAC,UAAU,GAAa,EAAG,CAAC,EAAgB,EAAY,EAAU,EAAS,CAAC,CAAC,MAAc,CAAC,GAAG,GAAW,EAAY,EAAE,CAAC,IAAM,EAAS,gBAAgB,CAAC,EAAe,GAAU,GAAM,GAAG,cAAc,EAAS,CAAQ,GAAU,EAAK,IAAM,EAAG,GAAG,CAAC,UAAU,cAAc,EAAS,GAAI,CAAC,EAAU,CAAC,CAAqB,EAAK,MAAM,CAAK,MAAI,MAAM,EAAM,MAAM,SAAS,GAAuB,EAAK,EAAU,CAAC,GAAG,EAAM,SAAS,EAAY,CAAC,CAAC,CAAC,mBADrzB,IAA6C,IAAyD"}