{"version":3,"file":"TextRevealOnScroll.Bm2wFyor.mjs","names":[],"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,GAAG,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,IAAI,EAAE,MAAM,CAAE,GAAE,CAAI,IAAO,OAAc,EAAK,MAAM,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,IAAI,EAAE,MAAM,CAAE,GAAE,CAAI,IAAO,OAAc,EAAK,MAAM,OAAO,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,IAAI,EAA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