{"version":3,"file":"Scroll_Text_Reveal.CEce45TF.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/fW0u2SCfArwppYOSVY5j/sbJ2YgSJ9XqRKsehWmAF/Scroll_Text_Reveal.js"],"sourcesContent":["\"use client\";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,useEffect,useState}from\"react\";// ─── Character ───────────────────────────────────────────────────────────────\nfunction EachCharacter({char,start,end,progress,index,transitionStartIndex,startColor,endColor}){const colorProgress=useTransform(progress,[start,end],[0,1],{clamp:true});const interpolatedColor=useTransform(colorProgress,[0,1],[startColor,endColor]);return /*#__PURE__*/_jsx(motion.span,{style:{color:index<transitionStartIndex?endColor:interpolatedColor,display:\"inline-block\",whiteSpace:\"pre\"},children:char});}// ─── Word ─────────────────────────────────────────────────────────────────────\nfunction EachWord({word,progress,starting,ending,transitionStartIndex,currentCharacterIndex,startColor,endColor}){const characters=word.split(\"\");const wordLength=characters.length;const amount=ending-starting;const step=wordLength>0?amount/wordLength:amount;return /*#__PURE__*/_jsxs(\"span\",{style:{display:\"inline-block\",whiteSpace:\"pre\"},children:[characters.map((char,idx)=>/*#__PURE__*/_jsx(EachCharacter,{char:char,start:starting+step*idx,end:starting+step*(idx+1),progress:progress,index:currentCharacterIndex+idx,transitionStartIndex:transitionStartIndex,startColor:startColor,endColor:endColor},idx)),/*#__PURE__*/_jsx(\"span\",{style:{display:\"inline-block\",width:\"0.25em\"}})]});}// ─── Animated inner — only ever rendered in the browser ──────────────────────\nfunction AnimatedText({words,totalWords,Tag,fontSize,lineHeight,letterSpacing,paragraphAlign,fontFamily,fontWeight,transitionStartIndex,startColor,endColor}){const ref=useRef(null);const{scrollYProgress}=useScroll({target:ref,offset:[\"start 0.75\",\"start 0.15\"]});let currentCharacterIndex=0;return /*#__PURE__*/_jsx(Tag,{ref:ref,style:{fontFamily,fontSize:`${fontSize}px`,display:\"flex\",flexWrap:\"wrap\",lineHeight:`${lineHeight}px`,letterSpacing:`${letterSpacing}px`,justifyContent:paragraphAlign,margin:0,padding:0,fontWeight,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,transitionStartIndex:transitionStartIndex,currentCharacterIndex:startIdx,startColor:startColor,endColor:endColor},`word-${idx}`);})});}// ─── Root export ──────────────────────────────────────────────────────────────\nexport default function RevealText(props){const{text=\"Hello Text\",duration=.3,easing=\"easeInOut\",fontSize=48,lineHeight=60,letterSpacing=-3,paragraphAlign=\"center\",transitionStartIndex=22,fontFamily=\"Urbanist\",fontWeight=400,startColor=\"#0000004D\",endColor=\"#000000\",headingTag=\"h1\"}=props;const[mounted,setMounted]=useState(false);useEffect(()=>{setMounted(true);},[]);const validTags=[\"p\",\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\"];const Tag=validTags.includes(headingTag)?headingTag:\"h1\";const words=(text||\"\").split(\" \").filter(Boolean);const totalWords=words.length;const sharedStyle={fontFamily,fontSize:`${fontSize}px`,lineHeight:`${lineHeight}px`,letterSpacing:`${letterSpacing}px`,margin:0,padding:0,fontWeight,width:\"100%\"};if(!mounted){return /*#__PURE__*/_jsx(Tag,{style:{...sharedStyle,display:\"flex\",flexWrap:\"wrap\",justifyContent:paragraphAlign,color:startColor},children:text});}return /*#__PURE__*/_jsx(AnimatedText,{words:words,totalWords:totalWords,Tag:Tag,fontSize:fontSize,lineHeight:lineHeight,letterSpacing:letterSpacing,paragraphAlign:paragraphAlign,fontFamily:fontFamily,fontWeight:fontWeight,transitionStartIndex:transitionStartIndex,startColor:startColor,endColor:endColor});}// ─── Property controls ───────────────────────────────────────────────────────\naddPropertyControls(RevealText,{text:{title:\"Text\",type:ControlType.String,defaultValue:\"Hello Text\",displayTextArea:true},headingTag:{title:\"HTML Tag\",type:ControlType.Enum,options:[\"p\",\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\"],optionTitles:[\"P\",\"H1\",\"H2\",\"H3\",\"H4\",\"H5\",\"H6\"],defaultValue:\"h1\"},fontFamily:{title:\"Font Family\",type:ControlType.String,defaultValue:\"Urbanist\"},fontSize:{title:\"Font Size\",type:ControlType.Number,defaultValue:48,min:10,max:200},fontWeight:{title:\"Font Weight\",type:ControlType.Number,defaultValue:400,min:100,max:900,step:100},lineHeight:{title:\"Line Height\",type:ControlType.Number,defaultValue:60,min:10,max:200},letterSpacing:{title:\"Letter Spacing\",type:ControlType.Number,defaultValue:-3,min:-10,max:10},paragraphAlign:{title:\"Paragraph Align\",type:ControlType.Enum,options:[\"flex-start\",\"center\",\"flex-end\"],optionTitles:[\"Left\",\"Center\",\"Right\"],defaultValue:\"center\"},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\",type:ControlType.Number,defaultValue:22,min:0,max:1e3},startColor:{title:\"Start Color\",type:ControlType.Color,defaultValue:\"#0000004D\"},endColor:{title:\"End Color\",type:ControlType.Color,defaultValue:\"#000000\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"RevealText\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Scroll_Text_Reveal.map"],"mappings":"8PACA,SAAS,EAAc,CAAC,OAAK,QAAM,MAAI,WAAS,QAAM,uBAAqB,aAAW,YAAU,CAA2E,IAAM,EAAkB,EAA9E,EAAa,EAAS,CAAC,EAAM,EAAI,CAAC,CAAC,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