{"version":3,"file":"ScrollProgressIndicator.CW19SA06.mjs","names":["useState","useRef"],"sources":["https:/framerusercontent.com/modules/VLjeIqhvoPuo9ZnFFSop/jBD2jBQ3ewg9LKmFymK4/ScrollProgressIndicator.js"],"sourcesContent":["// Scroll progress indicator with customizable colors and scroll speed\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useState,useRef,startTransition}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * @framerIntrinsicWidth 5\n * @framerIntrinsicHeight 300\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight fixed\n */export default function ScrollProgressIndicator(props){const{backgroundColor,fillColor}=props;const[scrollProgress,setScrollProgress]=useState(0);const rafRef=useRef();const containerRef=useRef(null);useEffect(()=>{if(typeof window===\"undefined\")return;const handleScroll=()=>{if(rafRef.current){cancelAnimationFrame(rafRef.current);}rafRef.current=requestAnimationFrame(()=>{if(!containerRef.current)return;const rect=containerRef.current.getBoundingClientRect();const componentBottom=rect.bottom;const viewportCenter=window.innerHeight/2;// Calculate progress: 0% when bottom is at bottom of viewport, 100% when bottom reaches center\nconst distanceFromBottom=window.innerHeight-componentBottom;const totalDistance=window.innerHeight-viewportCenter;const rawProgress=distanceFromBottom/totalDistance;const clampedProgress=Math.max(0,Math.min(100,rawProgress*100));startTransition(()=>{setScrollProgress(clampedProgress);});});};handleScroll();window.addEventListener(\"scroll\",handleScroll,{passive:true});return()=>{window.removeEventListener(\"scroll\",handleScroll);if(rafRef.current){cancelAnimationFrame(rafRef.current);}};},[]);return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:{...props.style,position:\"relative\",width:\"100%\",height:\"100%\",backgroundColor:backgroundColor,overflow:\"hidden\"},children:/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",top:0,left:0,width:\"100%\",height:`${scrollProgress}%`,backgroundColor:fillColor}})});}addPropertyControls(ScrollProgressIndicator,{backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#EEEEEE\"},fillColor:{type:ControlType.Color,title:\"Fill Color\",defaultValue:\"#000000\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ScrollProgressIndicator\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"fixed\",\"framerContractVersion\":\"1\",\"framerIntrinsicHeight\":\"300\",\"framerIntrinsicWidth\":\"5\",\"framerSupportedLayoutHeight\":\"fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ScrollProgressIndicator.map"],"mappings":"wMAMG,SAAwB,EAAwB,EAAM,CAAC,GAAK,CAAC,kBAAgB,aAAW,EAAW,CAAC,EAAe,GAAmBA,EAAS,EAAE,CAAO,EAAOC,GAAQ,CAAO,EAAaA,EAAO,KAAK,CACsS,OADrS,MAAc,CAAC,GAAU,IAAS,OAAY,OAAO,IAAM,MAAiB,CAAI,EAAO,SAAS,qBAAqB,EAAO,QAAQ,CAAE,EAAO,QAAQ,0BAA0B,CAAC,GAAG,CAAC,EAAa,QAAQ,OAA+D,IAAM,EAAnD,EAAa,QAAQ,uBAAuB,CAA4B,OAAa,EAAe,EAAO,YAAY,EACra,GAA/F,EAAO,YAAY,IAAoC,EAAO,YAAY,GAAwE,EAAgB,KAAK,IAAI,EAAE,KAAK,IAAI,IAAI,EAAY,IAAI,CAAC,CAAC,MAAoB,CAAC,EAAkB,EAAgB,EAAG,EAAG,EAAgF,OAA7E,GAAc,CAAC,EAAO,iBAAiB,SAAS,EAAa,CAAC,QAAQ,GAAK,CAAC,KAAW,CAAC,EAAO,oBAAoB,SAAS,EAAa,CAAI,EAAO,SAAS,qBAAqB,EAAO,QAAQ,GAAM,EAAE,CAAC,CAAqB,EAAK,MAAM,CAAC,IAAI,EAAa,MAAM,CAAC,GAAG,EAAM,MAAM,SAAS,WAAW,MAAM,OAAO,OAAO,OAAuB,kBAAgB,SAAS,SAAS,CAAC,SAAsB,EAAK,MAAM,CAAC,MAAM,CAAC,SA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