{"version":3,"file":"TextColorTransform.DGJC5pKu.mjs","names":["useRef","__esmMin","init_npm_react_18_3_1","p","c","init_jsx_runtime","de","useTransform","motion","useScroll","init_framer_motion_DhsWWWsN","addPropertyControls","init_framer_DcxuU94H","ControlType","AnimatedTextColor","props","words","text","totalWords","ref","currentCharacterIndex","font","colorFrom","starting","idx","ending","wordLength","word","startIdx","EachWord","scrollYProgress","EachCharacter","init_TextColorTransform","colorProgress","progress","start","end","colorTo","initialColor","index","transitionStartIndex","easing","char","characters","step","charStart","charEnd"],"sources":["https:/framerusercontent.com/modules/415vn8u4op4lRRnQHiln/ZG2UAPYABr6gDU81M4dr/TextColorTransform.js"],"sourcesContent":["// Animated Text Color on Scroll\n// User: Create a component that animates letter color on scroll, with property controls for text, color, and transition controls\nimport{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,colorFrom,colorTo})=>{const colorProgress=useTransform(progress,[start,end],[colorFrom,colorTo]);const initialColor=index<transitionStartIndex?colorTo:colorFrom;return /*#__PURE__*/_jsx(motion.span,{style:{color:index<transitionStartIndex?initialColor:colorProgress},transition:{duration:duration,ease:easing},children:char});};const EachWord=({word,progress,starting,ending,duration,easing,transitionStartIndex,currentCharacterIndex,colorFrom,colorTo})=>{const characters=word.split(\"\");const wordLength=word.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,colorFrom:colorFrom,colorTo:colorTo},idx);}),\"\\xa0\"]});};/**\n * Animated Text Color On Scroll\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight auto\n */export default function AnimatedTextColor(props){const{text,duration,easing,transitionStartIndex,colorFrom,colorTo,font,textTransform}=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:{...font,color:colorFrom,display:\"flex\",flexWrap:\"wrap\",justifyContent:font?.textAlign||\"center\",margin:0,width:\"100%\",height:\"100%\",textTransform:textTransform},children:words.map((word,idx)=>{const starting=idx/totalWords;const ending=(idx+1)/totalWords;const wordLength=word.length;const startIdx=currentCharacterIndex;currentCharacterIndex+=wordLength+1// Including space\n;return /*#__PURE__*/_jsx(EachWord,{word:word,progress:scrollYProgress,starting:starting,ending:ending,duration:duration,easing:easing,transitionStartIndex:transitionStartIndex,currentCharacterIndex:startIdx,colorFrom:colorFrom,colorTo:colorTo},idx);})});}AnimatedTextColor.displayName=\"AnimatedTextColor\";addPropertyControls(AnimatedTextColor,{text:{title:\"Text\",type:ControlType.String,defaultValue:\"Hello Text\",displayTextArea:true},font:{type:ControlType.Font,title:\"Font\",defaultValue:{fontSize:\"48px\",variant:\"Bold\",letterSpacing:\"-0.03em\",lineHeight:\"1.3em\"},controls:\"extended\",defaultFontType:\"sans-serif\"},textTransform:{title:\"Text Transform\",type:ControlType.Enum,options:[\"none\",\"uppercase\",\"lowercase\",\"capitalize\"],optionTitles:[\"None\",\"Uppercase\",\"Lowercase\",\"Capitalize\"],defaultValue:\"none\"},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:\"Transition Start Index\",type:ControlType.Number,defaultValue:22,min:0,max:1e3},colorFrom:{title:\"Start Color\",type:ControlType.Color,defaultValue:\"#CDCDCD\"},colorTo:{title:\"End Color\",type:ControlType.Color,defaultValue:\"#000000\"},textBalance:{title:\"Balance\",type:ControlType.Boolean,defaultValue:false,enabledTitle:\"Yes\",disabledTitle:\"No\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"AnimatedTextColor\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"auto\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TextColorTransform.map"],"mappings":"A,gPAOG,SAAwBc,EAAkB,EAAM,CAAC,GAAK,CAAC,OAAK,WAAS,SAAO,uBAAqB,YAAU,UAAQ,OAAK,iBAAeC,EAAYC,EAAMC,EAAK,MAAM,GAAG,EAAQC,EAAWF,EAAM,OAAaG,EAAInB,EAAO,IAAI,EAAO,CAAC,mBAAiBS,EAAU,CAAC,OAAOU,EAAI,OAAO,CAAC,aAAa,YAAY,CAAC,CAAC,EAAMC,EAAsB,EAAE,MAAoB,gBAAK,IAAI,CAAK,MAAI,MAAM,CAAC,GAAGC,EAAK,MAAMC,EAAU,QAAQ,OAAO,SAAS,OAAO,eAAeD,GAAM,WAAW,SAAS,OAAO,EAAE,MAAM,OAAO,OAAO,OAAqB,eAAa,EAAE,SAASL,EAAM,KAAK,EAAK,IAAM,CAAC,IAAMO,EAASC,EAAIN,EAAiBO,GAAQD,EAAI,GAAGN,EAAiBQ,EAAWC,EAAK,OAAaC,EAASR,EACtqB,MAD4rB,IAAuBM,EAAW,EAC1sB,gBAAKG,EAAS,CAAM,OAAK,SAASC,EAAyB,WAAgB,SAAgB,WAAgB,SAA4B,uBAAqB,sBAAsBF,EAAmB,YAAkB,SAAO,EAAEJ,CAAG,CAAE,CAAC,CAAC,CAAC,CAAE,C,sDANzD,GAAe,CAAC,OAAK,QAAM,MAAI,WAAS,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