{"version":3,"file":"CounterAnimator.ELLILZQa.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/bMRuHMKdINPACcGbmWo3/GBffuBeVDa8wGRr3kNxw/CounterAnimator.js"],"sourcesContent":["// Scroll-Triggered Counter Component that animates numbers when scrolling into view\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useRef,useState}from\"react\";import{addPropertyControls,ControlType}from\"framer\";import{useInView,motion,useTransform,useMotionValue,animate}from\"framer-motion\";/**\n * On Scroll Counter Animation\n *\n * @framerDisableUnlink\n *\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function CounterAnimator(props){const{startNumber=0,targetNumber=1e3,prefix=\"\",suffix=\"\",duration=2,delay=0,repeat=0,repeatType=\"loop\",repeatDelay=0,animationType=\"tween\",ease=\"easeOut\",stiffness=100,damping=20,mass=1,decimals=0,separator=true,font,color,alignment=\"center\"}=props;const ref=useRef(null);const[hasAnimated,setHasAnimated]=useState(false);const animControlsRef=useRef(null);const prevInViewRef=useRef(false);const motionValue=useMotionValue(startNumber);const displayValue=useTransform(motionValue,latest=>{const formatted=latest.toFixed(decimals);if(separator){const parts=formatted.split(\".\");parts[0]=parts[0].replace(/\\B(?=(\\d{3})+(?!\\d))/g,\",\");return parts.join(\".\");}return formatted;});const isInView=useInView(ref,{once:!(props.replayOnScroll??true),margin:props.viewportMargin??\"-100px\",amount:props.viewportAmount??0});useEffect(()=>{const common={delay,repeat,repeatType,repeatDelay};const options=animationType===\"spring\"?{type:\"spring\",stiffness,damping,mass,...common}:{type:\"tween\",duration,ease,...common};const startTo=to=>{animControlsRef.current?.stop();animControlsRef.current=animate(motionValue,to,options);};const wasInView=prevInViewRef.current;// Enter edge\nif(isInView&&!wasInView){if(!(props.replayOnScroll===false&&hasAnimated)){motionValue.set(startNumber);startTo(targetNumber);setHasAnimated(true);}}// Exit edge\nif(!isInView&&wasInView){if(props.reverseOnExit??true){startTo(startNumber);}if(props.replayOnScroll??true){setHasAnimated(false);}}prevInViewRef.current=isInView;},[isInView,targetNumber,animationType,duration,ease,stiffness,damping,mass,delay,repeat,repeatType,repeatDelay,motionValue,hasAnimated,props.replayOnScroll,props.reverseOnExit,startNumber]);return /*#__PURE__*/_jsx(\"div\",{ref:ref,style:{...props.style,position:\"relative\",display:\"flex\",justifyContent:alignment===\"left\"?\"flex-start\":alignment===\"right\"?\"flex-end\":\"center\",alignItems:\"center\",width:\"100%\",height:\"100%\"},children:/*#__PURE__*/_jsxs(motion.span,{style:{...font,color,whiteSpace:\"nowrap\",width:\"max-content\"},children:[prefix,/*#__PURE__*/_jsx(motion.span,{children:displayValue}),suffix]})});}addPropertyControls(CounterAnimator,{startNumber:{type:ControlType.Number,title:\"Start Number\",defaultValue:0,step:1},targetNumber:{type:ControlType.Number,title:\"Target Number\",defaultValue:1e3,min:0,step:1},prefix:{type:ControlType.String,title:\"Prefix\",defaultValue:\"\",placeholder:\"$\"},suffix:{type:ControlType.String,title:\"Suffix\",defaultValue:\"+\",placeholder:\"%\"},duration:{type:ControlType.Number,title:\"Duration\",defaultValue:2,min:.5,step:.1,unit:\"s\"},delay:{type:ControlType.Number,title:\"Delay\",defaultValue:0,min:0,step:.1,unit:\"s\"},animationType:{type:ControlType.Enum,title:\"Type\",options:[\"tween\",\"spring\"],optionTitles:[\"Tween\",\"Spring\"],defaultValue:\"tween\",displaySegmentedControl:true},ease:{type:ControlType.Enum,title:\"Ease\",options:[\"linear\",\"easeIn\",\"easeOut\",\"easeInOut\",\"circIn\",\"circOut\",\"circInOut\"],optionTitles:[\"Linear\",\"Ease In\",\"Ease Out\",\"Ease InOut\",\"Circ In\",\"Circ Out\",\"Circ InOut\"],defaultValue:\"easeOut\",hidden:props=>props.animationType!==\"tween\"},repeat:{type:ControlType.Number,title:\"Repeat\",defaultValue:0,min:0,step:1},repeatType:{type:ControlType.Enum,title:\"Repeat Type\",options:[\"loop\",\"reverse\",\"mirror\"],optionTitles:[\"Loop\",\"Reverse\",\"Mirror\"],defaultValue:\"loop\",hidden:props=>props.repeat===0},repeatDelay:{type:ControlType.Number,title:\"Repeat Delay\",defaultValue:0,min:0,step:.1,unit:\"s\",hidden:props=>props.repeat===0},stiffness:{type:ControlType.Number,title:\"Stiffness\",defaultValue:100,min:1,max:1e3,step:1,hidden:props=>props.animationType!==\"spring\"},damping:{type:ControlType.Number,title:\"Damping\",defaultValue:20,min:1,max:200,step:1,hidden:props=>props.animationType!==\"spring\"},mass:{type:ControlType.Number,title:\"Mass\",defaultValue:1,min:.1,max:10,step:.1,hidden:props=>props.animationType!==\"spring\"},decimals:{type:ControlType.Number,title:\"Decimals\",defaultValue:0,min:0,max:3,step:1,displayStepper:true},separator:{type:ControlType.Boolean,title:\"Separator\",defaultValue:true,enabledTitle:\"On\",disabledTitle:\"Off\"},alignment:{type:ControlType.Enum,title:\"Alignment\",options:[\"left\",\"center\",\"right\"],optionTitles:[\"Left\",\"Center\",\"Right\"],defaultValue:\"center\",displaySegmentedControl:true},color:{type:ControlType.Color,title:\"Color\",defaultValue:\"#000000\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"40px\",variant:\"Bold\",letterSpacing:\"-0.04em\",lineHeight:\"1em\"}},replayOnScroll:{type:ControlType.Boolean,title:\"Replay On Scroll\",defaultValue:true,enabledTitle:\"On\",disabledTitle:\"Off\"},reverseOnExit:{type:ControlType.Boolean,title:\"Reverse On Exit\",defaultValue:true,enabledTitle:\"On\",disabledTitle:\"Off\"},viewportMargin:{type:ControlType.String,title:\"Viewport Margin\",defaultValue:\"-100px\",placeholder:\"e.g. 0px 0px -20% 0px\",description:\"Root margin for in-view detection\"},viewportAmount:{type:ControlType.Number,title:\"Viewport Amount\",defaultValue:0,min:0,max:1,step:.05,description:\"Fraction of element that must be visible\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CounterAnimator\",\"slots\":[],\"annotations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