{"version":3,"file":"TextReveal.7jhur0BK.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/2fw1vihjCpS8h8YfrMzQ/7ujijNHeSycFblSxBGAC/TextReveal.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useRef,useEffect,useState}from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";/**\n * TextReveal - Smooth word-by-word text reveal on scroll\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight auto\n */export default function TextReveal(props){const{text=\"This text unblurs and fades in word by word as you scroll\",baseColor=\"#888888\",revealColor=\"#000000\",font={fontSize:24,lineHeight:1.5,letterSpacing:\"0em\",textAlign:\"left\"},fullRevealDistance=1e3,initialBlur=3,tag=\"p\",fitText=false,minFontSize=16,maxFontSize=72,style={}}=props;const outerRef=useRef(null);const containerRef=useRef(null);const words=text.split(\" \");const[scrollProgress,setScrollProgress]=useState(0);const[fontSize,setFontSize]=useState(font.fontSize||24);const isCanvas=RenderTarget.current()===RenderTarget.canvas;const Tag=tag;// 🔠 Responsive font size\nuseEffect(()=>{if(!fitText)return;const updateSize=()=>{if(!containerRef.current)return;const w=containerRef.current.offsetWidth||window.innerWidth;const base=parseInt(font.fontSize)||24;const scaled=base*(w/1e3);setFontSize(Math.max(minFontSize,Math.min(maxFontSize,scaled)));};updateSize();window.addEventListener(\"resize\",updateSize);return()=>window.removeEventListener(\"resize\",updateSize);},[fitText,font.fontSize,minFontSize,maxFontSize]);// 🌀 Scroll progress tracking\nuseEffect(()=>{if(isCanvas)return;const handleScroll=()=>{if(!outerRef.current)return;const rect=outerRef.current.getBoundingClientRect();const windowHeight=window.innerHeight;// 🔧 Adjust the reveal to finish before section ends:\n// We’ll map the scroll progress so that animation completes\n// when ~80% of the section has passed through the viewport.\nconst start=windowHeight*.2;const end=windowHeight*.8+fullRevealDistance*.5;const progress=Math.min(1,Math.max(0,1-(rect.top-start)/(end-start)));setScrollProgress(progress);};handleScroll();window.addEventListener(\"scroll\",handleScroll);window.addEventListener(\"resize\",handleScroll);return()=>{window.removeEventListener(\"scroll\",handleScroll);window.removeEventListener(\"resize\",handleScroll);};},[fullRevealDistance,isCanvas]);return /*#__PURE__*/_jsx(\"div\",{ref:outerRef,style:{display:\"flex\",alignItems:\"flex-start\",justifyContent:\"flex-start\",width:\"100%\",...style},children:/*#__PURE__*/_jsx(Tag,{ref:containerRef,style:{position:\"sticky\",top:0,margin:0,padding:0,fontFamily:font.fontFamily,fontWeight:font.fontWeight,fontSize:fitText?`${fontSize}px`:font.fontSize,lineHeight:font.lineHeight,letterSpacing:font.letterSpacing,textAlign:font.textAlign},children:words.map((word,i)=>{const progress=isCanvas?1:Math.max(0,Math.min(1,scrollProgress*words.length-i));const blur=initialBlur*(1-progress);const opacity=progress;const color=progress>=.9?revealColor:baseColor;return /*#__PURE__*/_jsx(\"span\",{style:{display:\"inline-block\",marginRight:\"0.25em\",filter:`blur(${blur}px)`,color,opacity,transition:\"filter 0.3s ease, color 0.3s ease, opacity 0.3s ease\"},children:word},i);})})});}addPropertyControls(TextReveal,{text:{type:ControlType.String,title:\"Text\",displayTextArea:true},baseColor:{type:ControlType.Color,title:\"Base Color\"},revealColor:{type:ControlType.Color,title:\"Reveal Color\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\"},fullRevealDistance:{type:ControlType.Number,title:\"Reveal Distance\",min:100,max:5e3,step:10,defaultValue:1e3},initialBlur:{type:ControlType.Number,title:\"Initial Blur\",min:0,max:10,step:.5,defaultValue:3},tag:{type:ControlType.Enum,title:\"Tag\",options:[\"p\",\"h1\",\"h2\",\"h3\"],optionTitles:[\"P\",\"H1\",\"H2\",\"H3\"],defaultValue:\"p\",displaySegmentedControl:true},fitText:{type:ControlType.Boolean,title:\"Responsive Text\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"},minFontSize:{type:ControlType.Number,title:\"Min Font Size\",defaultValue:16,hidden:({fitText})=>!fitText},maxFontSize:{type:ControlType.Number,title:\"Max Font Size\",defaultValue:72,hidden:({fitText})=>!fitText}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TextReveal\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"auto\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TextReveal.map"],"mappings":"8MAKG,SAAwB,EAAW,EAAM,CAAC,GAAK,CAAC,OAAK,4DAA4D,YAAU,UAAU,cAAY,UAAU,OAAK,CAAC,SAAS,GAAG,WAAW,IAAI,cAAc,MAAM,UAAU,OAAO,CAAC,qBAAmB,IAAI,cAAY,EAAE,MAAI,IAAI,UAAQ,GAAM,cAAY,GAAG,cAAY,GAAG,QAAM,EAAE,EAAE,EAAY,EAASA,EAAO,KAAK,CAAO,EAAaA,EAAO,KAAK,CAAO,EAAM,EAAK,MAAM,IAAI,CAAM,CAAC,EAAe,GAAmBC,EAAS,EAAE,CAAM,CAAC,EAAS,GAAaA,EAAS,EAAK,UAAU,GAAG,CAAO,EAAS,EAAa,SAAS,GAAG,EAAa,OAAa,EAAI,EAKzK,OAJ/a,MAAc,CAAC,GAAG,CAAC,EAAQ,OAAO,IAAM,MAAe,CAAC,GAAG,CAAC,EAAa,QAAQ,OAAO,IAAM,EAAE,EAAa,QAAQ,aAAa,EAAO,WAAwD,GAAlC,SAAS,EAAK,SAAS,EAAE,KAAsB,EAAE,KAAK,EAAY,KAAK,IAAI,EAAY,KAAK,IAAI,EAAY,EAAO,CAAC,CAAC,EAA6D,OAA1D,GAAY,CAAC,EAAO,iBAAiB,SAAS,EAAW,KAAW,EAAO,oBAAoB,SAAS,EAAW,EAAG,CAAC,EAAQ,EAAK,SAAS,EAAY,EAAY,CAAC,CAC7b,MAAc,CAAC,GAAG,EAAS,OAAO,IAAM,MAAiB,CAAC,GAAG,CAAC,EAAS,QAAQ,OAAO,I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