{"version":3,"file":"Text_Aim.CtxAk10W.mjs","names":["useRef"],"sources":["https:/framerusercontent.com/modules/mHZIIKEnmUF8huojrjg3/h3ab8pPVBUjSLB3E1KMr/Text_Aim.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useRef}from\"react\";import{motion,useMotionValue,useTransform,useSpring}from\"framer-motion\";import{addPropertyControls,ControlType}from\"framer\";export default function TextFillOnScroll({text,fontSize,fontFamily,fontWeight,textAlign,color01,color02,visibilityThreshold=0,as=\"div\"}){const containerRef=useRef(null);const progress=useMotionValue(0);const smoothProgress=useSpring(progress,{stiffness:60,damping:20,mass:.5});const clipPath=useTransform(smoothProgress,v=>`inset(0 0 ${100-v*100}% 0)`);useEffect(()=>{const onScroll=()=>{if(!containerRef.current)return;const rect=containerRef.current.getBoundingClientRect();const windowHeight=window.innerHeight||document.documentElement.clientHeight;if(rect.top<windowHeight&&rect.bottom>0){const visiblePx=Math.min(rect.bottom,windowHeight)-Math.max(rect.top,0);const ratio=visiblePx/rect.height;const clamped=Math.min(Math.max(ratio,0),1);if(clamped>=visibilityThreshold){progress.set(clamped);}else{progress.set(0);}}else{progress.set(0);}};window.addEventListener(\"scroll\",onScroll,{passive:true});onScroll();return()=>window.removeEventListener(\"scroll\",onScroll);},[progress,visibilityThreshold]);const Tag=as;return /*#__PURE__*/_jsxs(\"div\",{ref:containerRef,style:{position:\"relative\",fontSize:`${fontSize}px`,fontFamily,fontWeight,lineHeight:1.1,textAlign,whiteSpace:\"pre-wrap\",color:color01},children:[/*#__PURE__*/_jsx(Tag,{children:text}),/*#__PURE__*/_jsx(motion.div,{style:{position:\"absolute\",top:0,left:0,width:\"100%\",height:\"100%\",whiteSpace:\"pre-wrap\",color:color02,WebkitTextFillColor:\"transparent\",backgroundColor:color02,WebkitBackgroundClip:\"text\",backgroundClip:\"text\",pointerEvents:\"none\",clipPath:clipPath},\"aria-hidden\":\"true\",children:text})]});}addPropertyControls(TextFillOnScroll,{text:{type:ControlType.String,defaultValue:\"Scroll\\nto\\nfill\",title:\"Text\"},fontSize:{type:ControlType.Number,defaultValue:40,min:10,max:200,unit:\"px\"},fontFamily:{type:ControlType.String,defaultValue:\"Arial\"},fontWeight:{type:ControlType.Enum,defaultValue:\"600\",options:[\"100\",\"200\",\"300\",\"400\",\"500\",\"600\",\"700\",\"800\",\"900\"]},textAlign:{type:ControlType.Enum,displaySegmentedControl:true,defaultValue:\"center\",options:[\"left\",\"center\",\"right\"],optionTitles:[\"Left\",\"Center\",\"Right\"]},color01:{title:\"Base Color\",type:ControlType.Color,defaultValue:\"#000000\"},color02:{title:\"Fill Color\",type:ControlType.Color,defaultValue:\"#ff4081\"},visibilityThreshold:{title:\"Visibility Threshold\",type:ControlType.Number,defaultValue:.2,min:0,max:1,step:.05},as:{type:ControlType.Enum,title:\"Tag\",defaultValue:\"div\",options:[\"div\",\"p\",\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\"]}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TextFillOnScroll\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Text_Aim.map"],"mappings":"8bAAyN,SAAwB,EAAiB,CAAC,OAAK,WAAS,aAAW,aAAW,YAAU,UAAQ,UAAQ,sBAAoB,EAAE,KAAG,OAAO,CAAC,IAAM,EAAaA,EAAO,KAAK,CAAO,EAAS,EAAe,EAAE,CAAO,EAAe,EAAU,EAAS,CAAC,UAAU,GAAG,QAAQ,GAAG,KAAK,GAAG,CAAC,CAAO,EAAS,EAAa,EAAe,GAAG,aAAa,IAAI,EAAE,IAAI,MAAM,CAAC,MAAc,CAAC,IAAM,MAAa,CAAC,GAAG,CAAC,EAAa,QAAQ,OAAO,IAAM,EAAK,EAAa,QAAQ,uBAAuB,CAAO,EAAa,EAAO,aAAa,SAAS,gBAAgB,aAAa,GAAG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