{"version":3,"file":"Text_Opacity_Letters.BoUPTHOS.mjs","names":["useMemo","useRef"],"sources":["https:/framerusercontent.com/modules/7zmc5TyGGlO8sGS25MJU/iUPCR9rJvKW4bGbUNCzr/Text_Opacity_Letters.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{motion,useScroll,useTransform}from\"framer-motion\";import{useMemo,useRef}from\"react\";const EachCharacter=({char,start,end,progress,duration,easing,index,transitionStartIndex,startColor,endColor})=>{const colorProgress=useTransform(progress,[start,end],[startColor,endColor]);// Characters before transitionStartIndex appear as already \"finished\"\nconst initialColor=index<transitionStartIndex?endColor:startColor;return /*#__PURE__*/_jsx(motion.span,{style:{color:index<transitionStartIndex?initialColor:colorProgress},transition:{duration,ease:easing},children:char});};const EachWord=({word,progress,starting,ending,duration,easing,transitionStartIndex,currentCharacterIndex,startColor,endColor})=>{const characters=word.split(\"\");const wordLength=characters.length;const amount=ending-starting;const step=amount/Math.max(wordLength,1);return /*#__PURE__*/_jsxs(motion.span,{style:{display:\"inline-flex\"},children:[characters.map((char,idx)=>{const charStart=starting+step*idx;const charEnd=starting+step*(idx+1);return /*#__PURE__*/_jsx(EachCharacter,{char:char,start:charStart,end:charEnd,progress:progress,duration:duration,easing:easing,index:currentCharacterIndex+idx,transitionStartIndex:transitionStartIndex,startColor:startColor,endColor:endColor},idx);}),/*#__PURE__*/_jsx(\"span\",{children:\"\\xa0\"})]});};// Helper to support both string fonts and typography tokens\nfunction resolveFont(fontProp){if(!fontProp)return{family:\"sans-serif\",weight:400};if(typeof fontProp===\"string\"){return{family:fontProp,weight:400};}return{family:fontProp.fontFamily||\"sans-serif\",weight:typeof fontProp.fontWeight===\"number\"?fontProp.fontWeight:parseInt(fontProp.fontWeight,10)||400};}function mapTextAlignToJustify(textAlign){if(textAlign===\"center\")return\"center\";if(textAlign===\"right\")return\"flex-end\";return\"flex-start\";}export default function Text_Color_Letters(props){const{text,duration,easing,fontSize,lineHeight,letterSpacing,textAlign,transitionStartIndex,fontFamily,startColor,endColor,// New (optional) controls\nscrollStart,scrollEnd}=props;const words=useMemo(()=>(text||\"\").split(\" \").filter(Boolean),[text]);const totalWords=Math.max(words.length,1);const ref=useRef(null);/**\n     * Optimized scroll mapping:\n     * - 0% when the section's top reaches near the bottom of viewport (default: 0.9)\n     * - 100% when the section's center reaches the center of viewport (default: 0.5)\n     */const{scrollYProgress}=useScroll({target:ref,offset:[scrollStart,scrollEnd]});let currentCharacterIndex=0;const{family,weight}=resolveFont(fontFamily);const justifyContent=mapTextAlignToJustify(textAlign);return /*#__PURE__*/_jsx(\"p\",{ref:ref,style:{fontFamily:family,fontSize:`${fontSize}px`,fontWeight:weight,color:startColor,display:\"flex\",flexWrap:\"wrap\",lineHeight:`${lineHeight}px`,letterSpacing:`${letterSpacing}px`,justifyContent,margin:0,width:\"100%\"},children:words.map((word,idx)=>{const starting=idx/totalWords;const ending=(idx+1)/totalWords;const startIdx=currentCharacterIndex;currentCharacterIndex+=word.length+1;return /*#__PURE__*/_jsx(EachWord,{word:word,progress:scrollYProgress,starting:starting,ending:ending,duration:duration,easing:easing,transitionStartIndex:transitionStartIndex,currentCharacterIndex:startIdx,startColor:startColor,endColor:endColor},`${word}-${idx}`);})});}addPropertyControls(Text_Color_Letters,{text:{title:\"Text\",type:ControlType.String,defaultValue:\"Hello Text\"},fontFamily:{title:\"Font Family\",type:ControlType.Font,defaultValue:\"Newsreader\"},fontSize:{title:\"Font Size\",type:ControlType.Number,defaultValue:48,min:10,max:200},lineHeight:{title:\"Line Height\",type:ControlType.Number,defaultValue:60,min:10,max:240},letterSpacing:{title:\"Letter Spacing\",type:ControlType.Number,defaultValue:-3,min:-20,max:40},textAlign:{title:\"Text Align\",type:ControlType.Enum,options:[\"left\",\"center\",\"right\"],optionTitles:[\"Left\",\"Center\",\"Right\"],defaultValue:\"left\"},startColor:{title:\"Start Color\",type:ControlType.Color,defaultValue:\"#E6E5D6\"},endColor:{title:\"End Color\",type:ControlType.Color,defaultValue:\"#1A211B\"},duration:{title:\"Duration\",type:ControlType.Number,defaultValue:.3,min:.05,max:3,step:.05},easing:{title:\"Easing\",type:ControlType.Enum,options:[\"easeInOut\",\"easeIn\",\"easeOut\",\"linear\"],optionTitles:[\"Ease In Out\",\"Ease In\",\"Ease Out\",\"Linear\"],defaultValue:\"easeInOut\"},transitionStartIndex:{title:\"Transition Start Index\",type:ControlType.Number,defaultValue:22,min:0,max:5e3},// New controls to fine-tune the scroll feel in Framer\nscrollStart:{title:\"Scroll Start\",type:ControlType.String,defaultValue:\"start 0.9\"},scrollEnd:{title:\"Scroll End\",type:ControlType.String,defaultValue:\"center 0.5\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"Text_Color_Letters\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Text_Opacity_Letters.map"],"mappings":"kPAEA,SAAS,EAAY,EAAS,CAAwH,OAAnH,EAAmD,OAAO,GAAW,SAAgB,CAAC,OAAO,EAAS,OAAO,GAAG,EAAS,CAAC,OAAO,EAAS,YAAY,aAAa,OAAO,OAAO,EAAS,YAAa,SAAS,EAAS,WAAW,SAAS,EAAS,WAAW,EAAE,GAAG,GAAG,EAA1P,CAAC,OAAO,aAAa,OAAO,GAAG,CAA6N,CAAC,SAAS,EAAsB,EAAU,CAAgF,OAA5E,IAAY,SAAe,SAAY,IAAY,QAAc,WAAiB,YAAa,CAAC,SAAwB,EAAmB,EAAM,CAAC,GAAK,CAAC,OAAK,WAAS,SAAO,WAAS,aAAW,gBAAc,YAAU,uBAAqB,aAAW,aAAW,WAChmB,cAAY,aAAW,EAAY,EAAMA,OAAa,GAAM,GAAA,CAAI,MAAM,GAAG,CAAC,CAAC,OAAO,OAAO,EAAE,CAAC,CAAI,CAAC,EAAQ,EAAW,KAAK,IAAI,EAAM,OAAO,CAA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