{"version":3,"file":"Scroll_Text_Reveal.CLitvobK.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,CAAG,EAAE,CAAC,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