{"version":3,"file":"Text_Opacity_Letters.CU9f14DF.mjs","names":["useRef"],"sources":["https:/framerusercontent.com/modules/m3VpovDElNJShak4TF97/CjKm711sMIMGEbrtPWRe/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{useRef}from\"react\";const EachCharacter=({char,start,end,progress,duration,easing,index,transitionStartIndex,fromColor,toColor})=>{// Animate from `fromColor` → `toColor` over this character's scroll range\nconst colorProgress=useTransform(progress,[start,end],[fromColor,toColor]);// Anything before `transitionStartIndex` is already in \"final\" color\nconst initialColor=index<transitionStartIndex?toColor:fromColor;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,fromColor,toColor})=>{const characters=word.split(\"\");const wordLength=characters.length;const amount=ending-starting;const step=amount/wordLength;return /*#__PURE__*/_jsxs(motion.span,{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,fromColor:fromColor,toColor:toColor},idx);}),\"\\xa0\"]});};export default function Text_Color_Letters(props){const{text,duration,easing,fontSize,lineHeight,letterSpacing,textAlign,transitionStartIndex,fontFamily,fromColor,toColor}=props;const words=text.split(\" \");const totalWords=words.length;const ref=useRef(null);const{scrollYProgress}=useScroll({target:ref,offset:[\"start 0.75\",\"start 0.15\"]});let currentCharacterIndex=0;return /*#__PURE__*/_jsx(\"p\",{ref:ref,style:{// This uses your Framer font / text style:\n// In the Font control you can pick any project text style you’ve created.\nfontFamily:fontFamily?.fontFamily,fontWeight:fontFamily?.fontWeight,fontStyle:fontFamily?.fontStyle,fontSize:`${fontSize}px`,lineHeight:`${lineHeight}px`,letterSpacing:`${letterSpacing}px`,color:toColor,display:\"flex\",flexWrap:\"wrap\",justifyContent:textAlign,margin:0},children:words.map((word,idx)=>{const starting=idx/totalWords;const ending=(idx+1)/totalWords;const wordLength=word.length;const startIdx=currentCharacterIndex;currentCharacterIndex+=wordLength+1// +1 for space\n;return /*#__PURE__*/_jsx(EachWord,{word:word,progress:scrollYProgress,starting:starting,ending:ending,duration:duration,easing:easing,transitionStartIndex:transitionStartIndex,currentCharacterIndex:startIdx,fromColor:fromColor,toColor:toColor},idx);})});}addPropertyControls(Text_Color_Letters,{text:{title:\"Text\",type:ControlType.String,defaultValue:\"Hello Text\"},// Pick any font / text style from your project here\nfontFamily:{title:\"Font\",type:ControlType.Font},fontSize:{title:\"Font Size\",type:ControlType.Number,defaultValue:48,min:10,max:100},lineHeight:{title:\"Line Height\",type:ControlType.Number,defaultValue:60,min:10,max:100},letterSpacing:{title:\"Letter Spacing\",type:ControlType.Number,defaultValue:-3,min:-10,max:10},textAlign:{title:\"Align\",type:ControlType.Enum,options:[\"flex-start\",\"center\",\"flex-end\"],optionTitles:[\"Left\",\"Center\",\"Right\"],defaultValue:\"flex-start\"},// 🎨 Color controls for both modes\nfromColor:{title:\"From Color\",type:ControlType.Color,defaultValue:\"#73799B\"},toColor:{title:\"To Color\",type:ControlType.Color,defaultValue:\"#F4F7FF\"},duration:{title:\"Duration\",type:ControlType.Number,defaultValue:.3,min:.1,max:3,step:.1},easing:{title:\"Easing\",type:ControlType.Enum,options:[\"easeInOut\",\"easeIn\",\"easeOut\",\"linear\"],optionTitles:[\"Ease In Out\",\"Ease In\",\"Ease Out\",\"Linear\"],defaultValue:\"easeInOut\"},transitionStartIndex:{title:\"Start Index\",type:ControlType.Number,defaultValue:22,min:0,max:1e3}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"Text_Color_Letters\",\"slots\":[],\"annotations\":{\"framerContractVers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