{"version":3,"file":"RevealText.zm8LMNgO.mjs","names":["useRef","useMemo","useRef","React"],"sources":["https:/framerusercontent.com/modules/h8ioHyt4BUxuvVCE1Q10/aTM6mEMGlM19JjX8exDe/AvoidLayoutJumping_Prod.js","https:/framerusercontent.com/modules/KREKDa9Xx4gYW941QmqQ/TfxOoG1D1lZ5PJwDWDzr/RevealText.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";import{useEffect,useRef}from\"react\";/**\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n *\n * @framerDisableUnlink\n */export default function AvoidLayoutJumping({direction,style}){const isCanvas=RenderTarget.current()===RenderTarget.canvas;const ref=useRef(null);const rafId=useRef();const vertical=direction===\"vertical\"||direction===\"both\";const horizontal=direction===\"horizontal\"||direction===\"both\";useEffect(()=>{if(isCanvas)return;const parent=ref.current?.parentElement?.parentElement;if(!parent)return;const container=parent.parentElement;if(!container)return;const updateSize=()=>{const rect=parent.getBoundingClientRect();if(horizontal){container.style.width=`${rect.width}px`;}if(vertical){container.style.height=`${rect.height}px`;}rafId.current=requestAnimationFrame(updateSize);};// Start the RAF loop\nrafId.current=requestAnimationFrame(updateSize);return()=>{if(rafId.current){cancelAnimationFrame(rafId.current);}if(container){if(horizontal){container.style.width=\"\";}if(vertical){container.style.height=\"\";}}};},[direction]);return /*#__PURE__*/_jsx(\"div\",{ref:ref,style:{...style}});}AvoidLayoutJumping.displayName=\"Layout Jump Preventer\";addPropertyControls(AvoidLayoutJumping,{direction:{type:ControlType.Enum,defaultValue:\"vertical\",options:[\"vertical\",\"horizontal\",\"both\"],optionTitles:[\"Vertical\",\"Horizontal\",\"Both\"],displaySegmentedControl:true,segmentedControlDirection:\"vertical\",// @ts-ignore\noptionIcons:[\"direction-vertical\",\"direction-horizontal\",\"direction-all\"],description:\"More components at [Framer University](https://frameruni.link/cc).\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"AvoidLayoutJumping\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerDisableUnlink\":\"\",\"framerSupportedLayoutWidth\":\"auto\",\"framerSupportedLayoutHeight\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./AvoidLayoutJumping_Prod.map","import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";import{motion,useScroll,useTransform,useSpring,useReducedMotion}from\"framer-motion\";import React,{useMemo,useRef,useEffect}from\"react\";function useGoogleFont(fontFamily){useEffect(()=>{if(!fontFamily)return;const id=`font-${fontFamily.replace(/\\s+/g,\"-\")}`;if(document.getElementById(id))return;const link=document.createElement(\"link\");link.id=id;link.rel=\"stylesheet\";const familyParam=fontFamily.trim().replace(/\\s+/g,\"+\");link.href=`https://fonts.googleapis.com/css2?family=${familyParam}:wght@400;500;700&display=swap`;document.head.appendChild(link);},[fontFamily]);}const srOnlyStyle={position:\"absolute\",width:\"1px\",height:\"1px\",padding:0,margin:\"-1px\",overflow:\"hidden\",clip:\"rect(0, 0, 0, 0)\",whiteSpace:\"nowrap\",border:0};// Smooth ease-in-out, fixed for all reveals\nconst ease=t=>t<.5?2*t*t:1-Math.pow(-2*t+2,2)/2;// How many characters fade at the same time. Higher = softer, more gradient-like front.\nconst REVEAL_SPREAD=8;const EachCharacter=/*#__PURE__*/React.memo(function EachCharacter({char,start,end,progress,dimOpacity}){const opacity=useTransform(progress,[start,end],[dimOpacity,1],{ease});return /*#__PURE__*/_jsx(motion.span,{style:{opacity,willChange:\"opacity\"},\"aria-hidden\":true,children:char});});export default function RevealText(props){const{text=\"Hello Text\",uppercase=false,fontFamily=\"Urbanist\",fontSize=48,fontWeight=\"400\",lineHeight=120,letterSpacing=-3,paragraphAlign=\"center\",color=\"#FFFFFF\",dimOpacity=.15}=props;useGoogleFont(fontFamily);const onCanvas=RenderTarget.current()===RenderTarget.canvas;const resolvedText=text||\"\";const words=useMemo(()=>resolvedText.split(/\\s+/).filter(Boolean),[resolvedText]);const wordsWithOffset=useMemo(()=>{let acc=0;return words.map(word=>{const chars=[...word];const startIndex=acc;acc+=chars.length;return{word,chars,startIndex};});},[words]);const totalChars=useMemo(()=>wordsWithOffset.reduce((sum,w)=>sum+w.chars.length,0)||1,[wordsWithOffset]);const reduceMotion=useReducedMotion();const ref=useRef(null);// Fixed behavior: reveal sweeps as the text passes through the band\n// just above the center of the screen.\nconst{scrollYProgress}=useScroll({target:ref,offset:[\"start 0.8\",\"end 0.45\"]});const progress=useSpring(scrollYProgress,{stiffness:120,damping:32,mass:.4});const spacing=1/totalChars;const window=spacing*REVEAL_SPREAD;const half=window/2;const unitlessLineHeight=Math.max(.5,Number(lineHeight)/100||1.2);const textAlign=paragraphAlign===\"flex-start\"?\"left\":paragraphAlign===\"flex-end\"?\"right\":paragraphAlign;const baseTextStyle={fontFamily:`${fontFamily}, system-ui, -apple-system, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, \"Noto Sans\", \"Liberation Sans\", sans-serif`,fontSize,fontWeight,display:\"block\",lineHeight:unitlessLineHeight,letterSpacing:`${letterSpacing}px`,textAlign,margin:0,color,textTransform:uppercase?\"uppercase\":\"none\",WebkitFontSmoothing:\"antialiased\",MozOsxFontSmoothing:\"grayscale\"};// On canvas (and with reduced motion) skip all the per-character motion\n// spans and render plain static text in the final color. This avoids\n// hundreds of useTransform subscriptions in the editor.\nif(onCanvas||reduceMotion){return /*#__PURE__*/_jsx(\"p\",{style:{...baseTextStyle,opacity:1},children:resolvedText});}return /*#__PURE__*/_jsxs(\"div\",{style:{position:\"relative\"},children:[/*#__PURE__*/_jsx(\"p\",{ref:ref,style:baseTextStyle,children:wordsWithOffset.map(({word,chars,startIndex},wIdx)=>/*#__PURE__*/_jsxs(React.Fragment,{children:[chars.map((ch,i)=>{const g=startIndex+i;const center=(g+.5)*spacing;let start=center-half;let end=center+half;if(start<0)start=0;if(end>1)end=1;if(end<=start)end=start+1e-4;return /*#__PURE__*/_jsx(EachCharacter,{char:ch,start:start,end:end,progress:progress,dimOpacity:dimOpacity},i);}),/*#__PURE__*/_jsx(\"span\",{\"aria-hidden\":true,children:\" \"})]},`${word}-${wIdx}`))}),/*#__PURE__*/_jsx(\"span\",{style:srOnlyStyle,\"aria-hidden\":false,children:resolvedText})]});}addPropertyControls(RevealText,{text:{title:\"Text\",type:ControlType.String,defaultValue:\"Hello Text\"},uppercase:{title:\"Uppercase\",type:ControlType.Boolean,defaultValue:false,enabledTitle:\"ON\",disabledTitle:\"OFF\"},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.Enum,options:[\"400\",\"500\",\"700\"],optionTitles:[\"Regular\",\"Medium\",\"Bold\"],defaultValue:\"400\"},lineHeight:{title:\"Line Height (%)\",type:ControlType.Number,defaultValue:120,min:80,max:200},letterSpacing:{title:\"Letter Spacing (px)\",type:ControlType.Number,defaultValue:-3,min:-10,max:10,step:.5},paragraphAlign:{title:\"Align\",type:ControlType.Enum,options:[\"left\",\"center\",\"right\"],optionTitles:[\"Left\",\"Center\",\"Right\"],defaultValue:\"center\"},color:{title:\"Color\",type:ControlType.Color,defaultValue:\"#FFFFFF\"},dimOpacity:{title:\"Dim Opacity\",type:ControlType.Number,defaultValue:.15,min:0,max:1,step:.05}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"RevealText\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./RevealText.map"],"mappings":"0RAKG,SAAwB,EAAmB,CAAC,YAAU,SAAO,CAAC,IAAM,EAAS,EAAa,QAAQ,IAAI,EAAa,OAAa,EAAIA,EAAO,IAAI,EAAQ,EAAMA,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