{"version":3,"file":"ScrollTextReveal.C0mL8JiC.mjs","names":["useRef","p","c"],"sources":["https:/framerusercontent.com/modules/HPdOgRWkE6wKQLcLC7TD/hTK5Ukc8z7gCd8UEpGJ7/ScrollTextReveal.js"],"sourcesContent":["// Scroll Text Reveal — each letter goes from a dim colour to the full colour as the\n// paragraph scrolls through the viewport (start at 85% of viewport, end at 25%).\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,useEffect}from\"react\";function Char({char,progress,start,end,fromColor,toColor}){const color=useTransform(progress,[start,end],[fromColor,toColor]);return /*#__PURE__*/_jsx(motion.span,{style:{color},children:char});}/**\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight auto\n * @framerIntrinsicWidth 600\n */export default function ScrollTextReveal(props){const{text,indent,fontFamily,fontSize,fontWeight,lineHeight,letterSpacing,align,fromColor,toColor,startOffset,endOffset,tag,paragraphGap=.6,startEdge=\"start\",endEdge=\"start\"}=props;const ref=useRef(null);const{scrollYProgress}=useScroll({target:ref,offset:[`${startEdge} ${startOffset/100}`,`${endEdge} ${endOffset/100}`]});useEffect(()=>{if(!fontFamily||typeof document===\"undefined\")return;const id=`str-font-${fontFamily.replace(/ /g,\"-\")}`;if(document.getElementById(id))return;const link=document.createElement(\"link\");link.id=id;link.rel=\"stylesheet\";link.href=`https://fonts.googleapis.com/css2?family=${fontFamily.replace(/ /g,\"+\")}:wght@300;400;500;600;700&display=swap`;document.head.appendChild(link);},[fontFamily]);// paragraphs: split on new lines or \"||\" — one continuous reveal across all of them\nconst paragraphs=(text||\"\").split(/\\s*\\|\\|\\s*|\\n+/).map(p=>p.trim()).filter(Boolean);const total=Math.max(1,paragraphs.join(\"\").replace(/ /g,\"\").length);let index=0;const Tag=tag||\"p\";return /*#__PURE__*/_jsx(Tag,{ref:ref,style:{margin:0,padding:0,width:\"100%\",fontFamily:`\"${fontFamily}\", sans-serif`,fontSize,fontWeight,lineHeight:`${lineHeight}em`,letterSpacing:`${letterSpacing}em`,textAlign:align,textIndent:indent,whiteSpace:\"normal\",wordSpacing:\"normal\"},children:paragraphs.map((para,p)=>{const words=para.split(\" \");return /*#__PURE__*/_jsx(\"span\",{style:{display:\"block\",marginTop:p>0?`${paragraphGap}em`:0,textIndent:p>0?0:indent},children:words.map((word,w)=>/*#__PURE__*/_jsxs(\"span\",{children:[/*#__PURE__*/_jsx(\"span\",{style:{display:\"inline-block\",whiteSpace:\"nowrap\",textIndent:0},children:word.split(\"\").map((char,c)=>{const i=index++;return /*#__PURE__*/_jsx(Char,{char:char,progress:scrollYProgress,start:i/total,end:(i+1)/total,fromColor:fromColor,toColor:toColor},c);})}),w<words.length-1?\" \":null]},w))},p);})});}ScrollTextReveal.defaultProps={text:\"Scroll to reveal this text letter by letter.\",indent:0,fontFamily:\"Inter Tight\",fontSize:64,fontWeight:400,lineHeight:1,letterSpacing:-.02,align:\"left\",fromColor:\"#4B4B4B\",toColor:\"#FFFFFF\",startOffset:85,endOffset:25,paragraphGap:.6,startEdge:\"start\",endEdge:\"start\",tag:\"p\"};addPropertyControls(ScrollTextReveal,{text:{type:ControlType.String,title:\"Text\",displayTextArea:true,description:\"New line or || starts a new paragraph\"},startEdge:{type:ControlType.Enum,title:\"Start Edge\",options:[\"start\",\"end\"],description:\"Element edge used for Start % (the original top-bottom = start + 100)\"},endEdge:{type:ControlType.Enum,title:\"End Edge\",options:[\"start\",\"end\"],description:\"Element edge used for End % (the original bottom-top = end + 0)\"},paragraphGap:{type:ControlType.Number,title:\"Paragraph Gap (em)\",min:0,max:3,step:.05},tag:{type:ControlType.Enum,title:\"Tag\",options:[\"p\",\"h1\",\"h2\",\"h3\"]},indent:{type:ControlType.Number,title:\"Indent\",min:0,max:800,unit:\"px\"},fontFamily:{type:ControlType.String,title:\"Font\"},fontSize:{type:ControlType.Number,title:\"Size\",min:8,max:240},fontWeight:{type:ControlType.Enum,title:\"Weight\",options:[300,400,500,600,700]},lineHeight:{type:ControlType.Number,title:\"Line H (em)\",min:.5,max:3,step:.05},letterSpacing:{type:ControlType.Number,title:\"Letter Sp (em)\",min:-.2,max:.5,step:.005},align:{type:ControlType.Enum,title:\"Align\",options:[\"left\",\"center\",\"right\"]},fromColor:{type:ControlType.Color,title:\"From\"},toColor:{type:ControlType.Color,title:\"To\"},startOffset:{type:ControlType.Number,title:\"Start %\",min:0,max:100,description:\"Viewport % where colouring starts\"},endOffset:{type:ControlType.Number,title:\"End %\",min:0,max:100,description:\"Viewport % where text is fully coloured\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ScrollTextReveal\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerIntrinsicWidth\":\"600\",\"framerSupportedLayoutHeight\":\"auto\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ScrollTextReveal.map"],"mappings":"wPAE0M,SAAS,EAAK,CAAC,OAAK,WAAS,QAAM,MAAI,YAAU,WAAS,CAAC,IAAM,EAAM,EAAa,EAAS,CAAC,EAAM,CAAG,EAAE,CAAC,EAAU,CAAO,CAAC,EAAE,OAAoB,EAAK,EAAO,KAAK,CAAC,MAAM,CAAC,OAAK,EAAE,SAAS,CAAI,CAAC,CAAE,CAIzY,SAAwB,EAAiB,EAAM,CAAC,GAAK,CAAC,OAAK,SAAO,aAAW,WAAS,aAAW,aAAW,gBAAc,QAAM,YAAU,UAAQ,cAAY,YAAU,MAAI,eAAa,GAAG,YAAU,QAAQ,UAAQ,SAAS,EAAY,EAAIA,EAAO,IAAI,EAAO,CAAC,mBAAiB,EAAU,CAAC,OAAO,EAAI,OAAO,CAAC,GAAG,EAAU,GAAG,EAAY,MAAM,GAAG,EAAQ,GAAG,EAAU,KAAK,CAAC,CAAC,EAAE,MAAc,CAAC,GAAG,CAAC,GAAY,OA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