{"version":3,"file":"Text_reveal.Bi4ASuQa.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/LzZo2tpf1MepiwZrr9rh/6eI3pjyJUOpRXjykSmWS/Text_reveal.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useRef,useEffect,useState}from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";export default function TextReveal(props){const{text=\"\",baseColor,revealColor,font,fontSize,lineHeight,letterSpacing,fullRevealDistance,initialBlur,textAlign,animationDuration,animationEasing,animationDelay,applyBlurToBase,revealMode,scrollTriggerOffset}=props;const containerRef=useRef(null);const animationFrameRef=useRef(null);const observerRef=useRef(null);const words=(text||\"\").split(\" \");const[scrollProgress,setScrollProgress]=useState(0);const isCanvas=RenderTarget.current()===RenderTarget.canvas;// Function to throttle events for better performance\nconst throttle=(func,delay)=>{let lastCall=0;return function(...args){const now=new Date().getTime();if(now-lastCall<delay){return;}lastCall=now;return func(...args);};};useEffect(()=>{if(isCanvas){// Return early in canvas mode - just show fully revealed text\nsetScrollProgress(1);return;}let startPosition=0;let containerHeight=0;let viewportHeight=window.innerHeight;// Update positions and dimensions\nconst updatePositions=()=>{if(!containerRef.current)return;const rect=containerRef.current.getBoundingClientRect();startPosition=window.pageYOffset+rect.top;containerHeight=rect.height;viewportHeight=window.innerHeight;};// Throttled scroll handler for better performance\nconst handleScroll=throttle(()=>{if(!containerRef.current)return;const currentScroll=window.pageYOffset;const elementTop=startPosition-currentScroll;const visibleHeight=viewportHeight-elementTop-scrollTriggerOffset;// Calculate scroll progress\nconst progress=(visibleHeight-containerHeight)/(fullRevealDistance-containerHeight);setScrollProgress(Math.max(0,Math.min(1,progress)));},16)// ~60fps\n;// Setup IntersectionObserver for better performance\nconst setupObserver=()=>{if(!containerRef.current)return;// Cleanup previous observer if it exists\nif(observerRef.current){observerRef.current.disconnect();}observerRef.current=new IntersectionObserver(entries=>{// Only run scroll handler when element is visible\nif(entries[0].isIntersecting){window.addEventListener(\"scroll\",handleScroll,{passive:true});handleScroll();}else{window.removeEventListener(\"scroll\",handleScroll);}},{rootMargin:\"200px 0px\"}// Start observing a bit before element comes into view\n);observerRef.current.observe(containerRef.current);};// Handle window resize and orientation changes\nconst handleResize=throttle(()=>{updatePositions();handleScroll();},100);// Initialize everything\nconst initialize=()=>{updatePositions();setupObserver();window.addEventListener(\"resize\",handleResize,{passive:true});window.addEventListener(\"orientationchange\",handleResize,{passive:true});};initialize();// Cleanup function\nreturn()=>{if(observerRef.current){observerRef.current.disconnect();}if(animationFrameRef.current){cancelAnimationFrame(animationFrameRef.current);}window.removeEventListener(\"scroll\",handleScroll);window.removeEventListener(\"resize\",handleResize);window.removeEventListener(\"orientationchange\",handleResize);};},[fullRevealDistance,isCanvas,scrollTriggerOffset]);// Calculate the number of steps needed for the animation\nconst animationSteps=words.length+1;// Function to calculate progress based on reveal mode\nconst calculateWordProgress=index=>{if(isCanvas)return 1;if(revealMode===\"sequential\"){// Sequential mode: words reveal one after another\nreturn scrollProgress*animationSteps-index;}else if(revealMode===\"together\"){// Together mode: all words reveal at the same pace\nreturn scrollProgress;}else{// Default to sequential\nreturn scrollProgress*animationSteps-index;}};return /*#__PURE__*/_jsxs(\"div\",{ref:containerRef,style:{position:\"sticky\",top:0,fontFamily:font?.fontFamily,fontWeight:font?.fontWeight,fontSize:`${fontSize}px`,lineHeight:lineHeight,letterSpacing:`${letterSpacing}em`,textAlign:textAlign,willChange:\"transform\",transform:\"translateZ(0)\"},children:[/*#__PURE__*/_jsx(\"div\",{className:\"sr-only\",style:{position:\"absolute\",width:\"1px\",height:\"1px\",padding:\"0\",margin:\"-1px\",overflow:\"hidden\",clip:\"rect(0, 0, 0, 0)\",whiteSpace:\"nowrap\",borderWidth:\"0\",color:revealColor},\"aria-live\":\"polite\",children:text}),/*#__PURE__*/_jsx(\"div\",{\"aria-hidden\":\"true\",children:words.map((word,index)=>{const wordProgress=calculateWordProgress(index);const progress=Math.max(0,Math.min(1,wordProgress));const shouldReveal=progress>.99;const blurAmount=initialBlur*(1-progress);return /*#__PURE__*/_jsx(\"span\",{style:{display:\"inline-block\",marginRight:\"0.25em\",filter:applyBlurToBase?`blur(${blurAmount}px)`:\"none\",color:shouldReveal?revealColor:baseColor,transition:`filter ${animationDuration}s ${animationEasing} ${animationDelay*index}s, color ${animationDuration}s ${animationEasing} ${animationDelay*index}s`,willChange:\"filter, color\"},children:word},index);})})]});}TextReveal.defaultProps={text:\"This text unblurs and fades in word by word as you scroll\",baseColor:\"#888888\",revealColor:\"#000000\",font:{fontFamily:\"Inter\",fontWeight:400},fontSize:24,lineHeight:1.5,letterSpacing:0,fullRevealDistance:1e3,initialBlur:3,textAlign:\"left\",animationDuration:.2,animationEasing:\"ease-out\",animationDelay:0,applyBlurToBase:true,revealMode:\"sequential\",scrollTriggerOffset:0};addPropertyControls(TextReveal,{text:{type:ControlType.String,title:\"Text\",description:\"The text to be revealed\"},baseColor:{type:ControlType.Color,title:\"Base Color\",description:\"Starting color of the text\"},revealColor:{type:ControlType.Color,title:\"Reveal Color\",description:\"Final color of the revealed text\"},font:{type:ControlType.Font,title:\"Font\"},fontSize:{type:ControlType.Number,title:\"Font Size (px)\",min:1,max:200,step:1,displayStepper:true},lineHeight:{type:ControlType.Number,title:\"Line Height (em)\",min:.5,max:3,step:.1,displayStepper:true},letterSpacing:{type:ControlType.Number,title:\"Letter Spacing (em)\",min:-.5,max:2,step:.01,displayStepper:true},fullRevealDistance:{type:ControlType.Number,title:\"Full Reveal Distance\",description:\"Scrolling distance required for complete reveal\",min:100,max:5e3,step:10,displayStepper:false},initialBlur:{type:ControlType.Number,title:\"Initial Blur (px)\",min:0,max:20,step:.5,displayStepper:true},textAlign:{type:ControlType.Enum,title:\"Text Align\",options:[\"left\",\"center\",\"right\"],optionTitles:[\"Left\",\"Center\",\"Right\"]},animationDuration:{type:ControlType.Number,title:\"Animation Duration (s)\",min:0,max:3,step:.1,displayStepper:true},animationEasing:{type:ControlType.Enum,title:\"Animation Easing\",options:[\"linear\",\"ease\",\"ease-in\",\"ease-out\",\"ease-in-out\"],optionTitles:[\"Linear\",\"Ease\",\"Ease In\",\"Ease Out\",\"Ease In Out\"]},animationDelay:{type:ControlType.Number,title:\"Animation Delay (s)\",description:\"Delay between each word's animation\",min:0,max:1,step:.01,displayStepper:true},revealMode:{type:ControlType.Enum,title:\"Reveal Mode\",description:\"How words are revealed during scroll\",options:[\"sequential\",\"together\"],optionTitles:[\"Sequential\",\"Together\"]},scrollTriggerOffset:{type:ControlType.Number,title:\"Scroll Trigger Offset\",description:\"Adjust when animation begins (+ starts earlier, - starts later)\",min:-500,max:500,step:10,displayStepper:true},applyBlurToBase:{type:ControlType.Boolean,title:\"Blur Effect\",defaultValue:true,enabledTitle:\"On\",disabledTitle:\"Off\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TextReveal\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Text_reveal.map"],"mappings":"oNAAuK,SAAwB,EAAW,EAAM,CAAC,GAAK,CAAC,OAAK,GAAG,YAAU,cAAY,OAAK,WAAS,aAAW,gBAAc,qBAAmB,cAAY,YAAU,oBAAkB,kBAAgB,iBAAe,kBAAgB,aAAW,uBAAqB,EAAY,EAAaA,EAAO,KAAK,CAAO,EAAkBA,EAAO,KAAK,CAAO,EAAYA,EAAO,KAAK,CAAO,GAAO,GAAM,IAAI,MAAM,IAAI,CAAM,CAAC,EAAe,GAAmBC,EAAS,EAAE,CAAO,EAAS,EAAa,SAAS,GAAG,EAAa,OACrpB,GAAU,EAAK,IAAQ,CAAC,IAAI,EAAS,EAAE,OAAO,SAAS,GAAG,EAAK,CAAC,IAAM,EAAI,IAAI,MAAM,CAAC,SAAS,CAAI,OAAI,EAAS,GAA4B,MAAb,GAAS,EAAW,EAAK,GAAG,EAAK,GAAK,MAAc,CAAC,GAAG,EA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