{"version":3,"file":"TextRevealOnScroll.Bt5AWjFf.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/iDsmYU2fhXZ0UOq8cFqV/pSwdC9zNVbtjwneM36hw/TextRevealOnScroll.js"],"sourcesContent":["// Text Reveal on Scroll\n// Reveals text per letter, word, or line as you scroll past. Base color and reveal color are configurable.\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useRef,useEffect,useState,startTransition}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";function splitText(text,mode){if(mode===\"letter\")return text.split(\"\").map((c,i)=>({key:i,value:c}));if(mode===\"word\")return text.split(/(\\s+)/).map((w,i)=>({key:i,value:w}));if(mode===\"line\")return text.split(/(\\n)/).map((l,i)=>({key:i,value:l}));return[{key:0,value:text}];}/**\n * Text Reveal on Scroll\n *\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function TextRevealOnScroll(props){const{text,revealMode,baseColor,revealColor,font,revealDistance,style}=props;const isStatic=useIsStaticRenderer();const containerRef=useRef(null);const[revealProgress,setRevealProgress]=useState(0);useEffect(()=>{if(isStatic){startTransition(()=>setRevealProgress(1));return;}function onScroll(){if(!containerRef.current)return;const rect=containerRef.current.getBoundingClientRect();const windowHeight=window.innerHeight||document.documentElement.clientHeight;// Calculate how much of the component is visible\nconst visible=Math.min(windowHeight,Math.max(0,windowHeight-rect.top));const total=Math.min(windowHeight,rect.height);let progress=visible/(total+revealDistance);progress=Math.max(0,Math.min(1,progress));startTransition(()=>setRevealProgress(progress));}window.addEventListener(\"scroll\",onScroll,{passive:true});window.addEventListener(\"resize\",onScroll);onScroll();return()=>{window.removeEventListener(\"scroll\",onScroll);window.removeEventListener(\"resize\",onScroll);};},[isStatic,revealDistance]);const items=splitText(text,revealMode);const revealedCount=Math.round(items.length*revealProgress);return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:{...style,position:\"relative\",display:\"block\",color:baseColor,...font,whiteSpace:revealMode===\"line\"?\"pre-line\":\"pre-wrap\"},children:items.map((item,i)=>/*#__PURE__*/_jsx(\"span\",{style:{color:i<revealedCount?revealColor:baseColor,transition:\"color 0.4s cubic-bezier(.4,0,.2,1)\",...font},\"aria-hidden\":\"true\",children:item.value},item.key))});}addPropertyControls(TextRevealOnScroll,{text:{type:ControlType.String,title:\"Text\",defaultValue:\"Reveal this text as you scroll.\",displayTextArea:true},revealMode:{type:ControlType.Enum,title:\"Reveal By\",options:[\"letter\",\"word\",\"line\"],optionTitles:[\"Letter\",\"Word\",\"Line\"],defaultValue:\"letter\",displaySegmentedControl:true},baseColor:{type:ControlType.Color,title:\"Base Color\",defaultValue:\"#CCCCCC\"},revealColor:{type:ControlType.Color,title:\"Reveal Color\",defaultValue:\"#222222\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"32px\",variant:\"Semibold\",letterSpacing:\"-0.01em\",lineHeight:\"1.2em\"}},revealDistance:{type:ControlType.Number,title:\"Reveal Distance\",defaultValue:100,min:0,max:500,unit:\"px\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TextRevealOnScroll\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"auto\",\"framerSupportedLayoutHeight\":\"auto\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TextRevealOnScroll.map"],"mappings":"0VAEgL,SAAS,EAAU,EAAK,EAAK,CAA2N,OAAvN,IAAO,SAAgB,EAAK,MAAM,IAAI,KAAK,EAAE,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,GAAM,IAAO,OAAc,EAAK,MAAM,SAAS,KAAK,EAAE,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,GAAM,IAAO,OAAc,EAAK,MAAM,QAAQ,KAAK,EAAE,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,GAAS,CAAC,CAAC,IAAI,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