{
  "version": 3,
  "sources": ["ssg: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": "qKAEgL,SAASA,EAAUC,EAAKC,EAAK,CAAC,OAAGA,IAAO,SAAgBD,EAAK,MAAM,EAAE,EAAE,IAAI,CAACE,EAAEC,KAAK,CAAC,IAAIA,EAAE,MAAMD,CAAC,EAAE,EAAKD,IAAO,OAAcD,EAAK,MAAM,OAAO,EAAE,IAAI,CAACI,EAAED,KAAK,CAAC,IAAIA,EAAE,MAAMC,CAAC,EAAE,EAAKH,IAAO,OAAcD,EAAK,MAAM,MAAM,EAAE,IAAI,CAACK,EAAEF,KAAK,CAAC,IAAIA,EAAE,MAAME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AMJ,EAAU,GAAGE,EAAK,WAAWH,IAAa,OAAO,WAAW,UAAU,EAAE,SAASsB,EAAM,IAAI,CAACG,EAAK,IAAiBD,EAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAED,EAAcrB,EAAYD,EAAU,WAAW,qCAAqC,GAAGE,CAAI,EAAE,cAAc,OAAO,SAASsB,EAAK,KAAK,EAAEA,EAAK,GAAG,CAAC,CAAC,CAAC,CAAE,CAACC,EAAoB5B,EAAmB,CAAC,KAAK,CAAC,KAAK6B,EAAY,OAAO,MAAM,OAAO,aAAa,kCAAkC,gBAAgB,EAAI,EAAE,WAAW,CAAC,KAAKA,EAAY,KAAK,MAAM,YAAY,QAAQ,CAAC,SAAS,OAAO,MAAM,EAAE,aAAa,CAAC,SAAS,OAAO,MAAM,EAAE,aAAa,SAAS,wBAAwB,EAAI,EAAE,UAAU,CAAC,KAAKA,EAAY,MAAM,MAAM,aAAa,aAAa,SAAS,EAAE,YAAY,CAAC,KAAKA,EAAY,MAAM,MAAM,eAAe,aAAa,SAAS,EAAE,KAAK,CAAC,KAAKA,EAAY,KAAK,MAAM,OAAO,SAAS,WAAW,gBAAgB,aAAa,aAAa,CAAC,SAAS,OAAO,QAAQ,WAAW,cAAc,UAAU,WAAW,OAAO,CAAC,EAAE,eAAe,CAAC,KAAKA,EAAY,OAAO,MAAM,kBAAkB,aAAa,IAAI,IAAI,EAAE,IAAI,IAAI,KAAK,IAAI,CAAC,CAAC",
  "names": ["splitText", "text", "mode", "c", "i", "w", "l", "TextRevealOnScroll", "props", "revealMode", "baseColor", "revealColor", "font", "revealDistance", "style", "isStatic", "useIsStaticRenderer", "containerRef", "pe", "revealProgress", "setRevealProgress", "ye", "ue", "Z", "onScroll", "rect", "windowHeight", "window", "visible", "total", "progress", "items", "revealedCount", "p", "item", "addPropertyControls", "ControlType"]
}
