{"version":3,"file":"NumericScrollProgress.DooxCmQM.mjs","names":["useState","useRef","useMemo"],"sources":["https:/framerusercontent.com/modules/bu5akYku1sCOX4wycen6/5ZVZ8zgUGZTmJbyS09fi/NumericScrollProgress.js"],"sourcesContent":["// User goal: create a numeric scroll progress component that scrolls with the page vertically.\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useState,useMemo,startTransition}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";import{useRef}from\"react\";/**\n * NumericScrollProgress\n *\n * Displays the vertical scroll progress (0–100%) as a number that updates while the page scrolls.\n *\n * @framerIntrinsicWidth 80\n * @framerIntrinsicHeight 40\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function NumericScrollProgress(props){const{textColor,backgroundColor,showBackground,borderRadius,font,style}=props;const isStatic=useIsStaticRenderer();const[progress,setProgress]=useState(0);const[visible,setVisible]=useState(false);const hideTimeoutRef=useRef(null);useEffect(()=>{if(isStatic)return;function calculateProgress(){if(typeof window===\"undefined\"||typeof document===\"undefined\")return;const scrollTop=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0;const docHeight=Math.max(document.body.scrollHeight,document.documentElement.scrollHeight,document.body.offsetHeight,document.documentElement.offsetHeight,document.body.clientHeight,document.documentElement.clientHeight);const viewportHeight=window.innerHeight||document.documentElement.clientHeight||0;const scrollable=Math.max(docHeight-viewportHeight,1);const raw=scrollTop/scrollable*100;const clamped=Math.min(Math.max(raw,0),100);startTransition(()=>{setProgress(Math.round(clamped));setVisible(true);});if(hideTimeoutRef.current!==null&&typeof window!==\"undefined\"){window.clearTimeout(hideTimeoutRef.current);}if(typeof window!==\"undefined\"){const timeoutId=window.setTimeout(()=>{startTransition(()=>{setVisible(false);});},600);hideTimeoutRef.current=timeoutId;}}if(typeof window!==\"undefined\"){window.addEventListener(\"scroll\",calculateProgress,{passive:true});window.addEventListener(\"resize\",calculateProgress);return()=>{window.removeEventListener(\"scroll\",calculateProgress);window.removeEventListener(\"resize\",calculateProgress);if(hideTimeoutRef.current!==null&&typeof window!==\"undefined\"){window.clearTimeout(hideTimeoutRef.current);}};}return;},[isStatic]);const displayText=useMemo(()=>`${progress}%`,[progress]);const isFixedWidth=style&&style.width===\"100%\";const isFixedHeight=style&&style.height===\"100%\";const isVisible=isStatic?true:visible;return /*#__PURE__*/_jsx(\"div\",{style:{position:\"relative\",display:\"inline-flex\",alignItems:\"center\",justifyContent:\"center\",padding:\"8px 12px\",color:textColor,backgroundColor:showBackground?backgroundColor:\"transparent\",borderRadius,boxSizing:\"border-box\",minWidth:isFixedWidth?undefined:\"max-content\",minHeight:isFixedHeight?undefined:\"max-content\",opacity:isVisible?1:0,transform:isVisible?\"translateY(0px)\":\"translateY(8px)\",transition:\"opacity 0.4s ease-out, transform 0.4s ease-out\",pointerEvents:isVisible?\"auto\":\"none\",...font,...style},\"aria-label\":`Scroll progress: ${progress} percent`,role:\"status\",children:/*#__PURE__*/_jsx(\"span\",{style:{width:\"max-content\",lineHeight:\"1em\",whiteSpace:\"nowrap\"},children:displayText})});}addPropertyControls(NumericScrollProgress,{textColor:{type:ControlType.Color,title:\"Text\",defaultValue:\"#000000\"},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#FFFFFF\"},showBackground:{type:ControlType.Boolean,title:\"Background\",defaultValue:true,enabledTitle:\"Show\",disabledTitle:\"Hide\"},borderRadius:{type:ControlType.Number,title:\"Radius\",defaultValue:8,min:0,max:48,step:1,unit:\"px\"},font:{type:ControlType.Font,title:\"Font\",defaultValue:{fontSize:\"15px\",variant:\"Medium\",letterSpacing:\"-0.01em\",lineHeight:\"1em\"},controls:\"extended\",defaultFontType:\"sans-serif\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"NumericScrollProgress\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\",\"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