{"version":3,"file":"ScrollRevealText.BykhGInu.mjs","names":["__legacyOverrideHOC_DataObserverContext","_jsx","useRef","useState","useMemo","useCallback"],"sources":["https:/framerusercontent.com/modules/TsYmWeEsWpgaBst121I2/2uN9Gd0FgakTMP3R4lb8/Set100svh.js","https:/framerusercontent.com/modules/9bEou7VVkLRlMEDq3qVi/ymTPX19qBC71Fs3GTCyB/ScrollRevealText.js"],"sourcesContent":["// ViewportSVH.tsx\n// Framer Code Override — forces a specific section to use 100svh.\nimport{jsx as _jsx}from\"react/jsx-runtime\";export function ViewportSVH(){return{style:{height:\"100svh\",minHeight:\"100svh\"}};}import{useContext as __legacyOverrideHOC_useContext}from\"react\";import{DataObserverContext as __legacyOverrideHOC_DataObserverContext}from\"framer\";export function withViewportSVH(C){return props=>{__legacyOverrideHOC_useContext(__legacyOverrideHOC_DataObserverContext);return _jsx(C,{...props,...ViewportSVH(props)});};}withViewportSVH.displayName=\"ViewportSVH\";\nexport const __FramerMetadata__ = {\"exports\":{\"ViewportSVH\":{\"type\":\"override\",\"name\":\"ViewportSVH\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withViewportSVH\":{\"type\":\"reactHoc\",\"name\":\"withViewportSVH\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Set100svh.map","// Optimized scroll-triggered text animation for better mobile performance\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useRef,useEffect,useState,useMemo,useCallback}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";// Throttle function for better performance\nfunction throttle(func,limit){let inThrottle;return function(...args){const context=this;if(!inThrottle){func.apply(context,args);inThrottle=true;setTimeout(()=>inThrottle=false,limit);}};}/**\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight fixed\n */export default function ScrollRevealText(props){const{text=\"Create amazing scroll animations with beautiful text reveals that captivate your audience.\\n\\nThis is a new paragraph that will have proper spacing and line breaks.\",fontSize=48,textColor=\"#000000\",font,textAlign=\"left\",unrevealedOpacity=.3,wordSpacing=.25,paragraphSpacing=.8,animationDuration=.2,scrollSectionId=\"\"}=props;const containerRef=useRef(null);const targetElementRef=useRef(null);const isStatic=useIsStaticRenderer();const[scrollProgress,setScrollProgress]=useState(0);const[visibleWordIndices,setVisibleWordIndices]=useState(new Set);// Memoize words processing - this was already good\nconst words=useMemo(()=>{let processedText=text.replace(/\\\\n\\\\n/g,\"\\n\\n\").replace(/\\\\n/g,\"\\n\");const paragraphs=processedText.split(/\\n\\s*\\n/);const wordsWithBreaks=[];paragraphs.forEach((paragraph,paragraphIndex)=>{const lines=paragraph.split(/\\n/);lines.forEach((line,lineIndex)=>{const lineWords=line.split(\" \").filter(word=>word.length>0);lineWords.forEach(word=>{wordsWithBreaks.push(word);});if(lineIndex<lines.length-1){wordsWithBreaks.push(\"__LINE_BREAK__\");}});if(paragraphIndex<paragraphs.length-1){wordsWithBreaks.push(\"__PARAGRAPH_BREAK__\");}});return wordsWithBreaks;},[text]);// Memoize actual words count for performance\nconst actualWords=useMemo(()=>words.filter(word=>word!==\"__PARAGRAPH_BREAK__\"&&word!==\"__LINE_BREAK__\"),[words]);// Cache target element lookup\nuseEffect(()=>{if(isStatic)return;if(scrollSectionId&&scrollSectionId.trim()!==\"\"){const idElement=document.getElementById(scrollSectionId);if(idElement){targetElementRef.current=idElement;}else{console.warn(`ScrollRevealText: Could not find element with ID \"${scrollSectionId}\"`);targetElementRef.current=containerRef.current?.parentElement||null;}}else{targetElementRef.current=containerRef.current?.parentElement||null;}},[scrollSectionId,isStatic]);// Optimized scroll handler with light throttling\nconst handleScroll=useCallback(throttle(()=>{if(!targetElementRef.current||isStatic)return;const rect=targetElementRef.current.getBoundingClientRect();const windowHeight=window.innerHeight;const elementTop=rect.top;const elementHeight=rect.height;// Simplified progress calculation\nconst startPoint=windowHeight*.5;const endPoint=-elementHeight+startPoint;const totalDistance=startPoint-endPoint;let progress=0;if(elementTop<=startPoint){if(elementTop>=endPoint){progress=(startPoint-elementTop)/totalDistance;}else{progress=1;}}progress=Math.max(0,Math.min(1.2,progress));setScrollProgress(progress);},16),[isStatic]);// Update visible words based on scroll progress\nuseEffect(()=>{if(isStatic){setVisibleWordIndices(new Set(Array.from({length:words.length},(_,i)=>i)));return;}const newVisibleIndices=new Set;words.forEach((word,index)=>{if(word===\"__PARAGRAPH_BREAK__\"||word===\"__LINE_BREAK__\"){newVisibleIndices.add(index);return;}const actualWordIndex=words.slice(0,index).filter(w=>w!==\"__PARAGRAPH_BREAK__\"&&w!==\"__LINE_BREAK__\").length;// Back to original calculation - now that progress can reach 1.05, last word will show\nconst wordProgress=actualWordIndex/Math.max(actualWords.length-1,1);const threshold=actualWordIndex===0?.01:0;if(scrollProgress>=wordProgress+threshold){newVisibleIndices.add(index);}});setVisibleWordIndices(newVisibleIndices);},[scrollProgress,words,actualWords.length,isStatic]);useEffect(()=>{if(isStatic){setScrollProgress(1);return;}// Use passive listener for better performance\nwindow.addEventListener(\"scroll\",handleScroll,{passive:true});// Initial call with slight delay to ensure DOM is ready\nconst timer=setTimeout(handleScroll,100);return()=>{window.removeEventListener(\"scroll\",handleScroll);clearTimeout(timer);};},[handleScroll,isStatic]);// Memoize style objects to prevent unnecessary re-renders\nconst containerStyle=useMemo(()=>({display:\"block\",width:\"100%\",overflow:\"visible\",position:\"relative\"}),[]);const flexStyle=useMemo(()=>({display:\"flex\",flexWrap:\"wrap\",columnGap:`${wordSpacing}em`,justifyContent:textAlign===\"center\"?\"center\":textAlign===\"right\"?\"flex-end\":\"flex-start\",alignItems:\"baseline\",lineHeight:font?.lineHeight||\"1.2\",width:\"fit-content\",maxWidth:\"100%\"}),[wordSpacing,textAlign,font?.lineHeight]);const wordStyle=useMemo(()=>({display:\"inline-block\",whiteSpace:\"normal\",fontSize:`${fontSize}px`,color:textColor,...font}),[fontSize,textColor,font]);return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:containerStyle,children:/*#__PURE__*/_jsx(\"div\",{style:flexStyle,children:words.map((word,index)=>{// Handle breaks\nif(word===\"__PARAGRAPH_BREAK__\"){return /*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",height:`${paragraphSpacing}em`}},`para-break-${index}`);}if(word===\"__LINE_BREAK__\"){return /*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",height:\"0px\"}},`line-break-${index}`);}const isVisible=visibleWordIndices.has(index);return /*#__PURE__*/_jsx(\"span\",{style:{...wordStyle,opacity:isVisible?1:unrevealedOpacity,transition:`opacity ${animationDuration}s ease-out`},children:word});})})});}addPropertyControls(ScrollRevealText,{scrollSectionId:{type:ControlType.String,title:\"Scroll Section ID\",defaultValue:\"\",placeholder:\"section-id\",description:\"ID of the scroll section to track (set in Framer's right panel)\"},text:{type:ControlType.String,title:\"Text\",defaultValue:\"Create amazing scroll animations with beautiful text reveals that captivate your audience.\\n\\nThis is a new paragraph that will have proper spacing and line breaks.\",displayTextArea:true},unrevealedOpacity:{type:ControlType.Number,title:\"Unrevealed Opacity\",defaultValue:.3,min:0,max:1,step:.1},animationDuration:{type:ControlType.Number,title:\"Animation Duration\",defaultValue:.2,min:.1,max:1,step:.05,unit:\"s\"},wordSpacing:{type:ControlType.Number,title:\"Word Spacing\",defaultValue:.25,min:0,max:2,step:.05,unit:\"em\"},paragraphSpacing:{type:ControlType.Number,title:\"Paragraph Spacing\",defaultValue:.8,min:0,max:3,step:.1,unit:\"em\"},textAlign:{type:ControlType.Enum,title:\"Text Align\",options:[\"left\",\"center\",\"right\"],optionTitles:[\"Left\",\"Center\",\"Right\"],defaultValue:\"left\",displaySegmentedControl:true},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"},font:{type:ControlType.Font,title:\"Font\",defaultValue:{fontSize:\"48px\",variant:\"Semibold\",lineHeight:\"1.1em\"},controls:\"extended\",defaultFontType:\"sans-serif\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ScrollRevealText\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"fixed\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ScrollRevealText.map"],"mappings":"0OAE2C,SAAgB,GAAa,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,SAAS,UAAU,SAAS,CAAC,CAAqJ,SAAgB,EAAgB,EAAE,CAAC,MAAO,KAAQ,EAA+BA,EAAwC,CAAQC,EAAK,EAAE,CAAC,GAAG,EAAM,GAAG,EAAY,EAAM,CAAC,CAAC,mBAA9Y,IAAkJ,IAAmF,CAA6K,EAAgB,YAAY,iBCAzd,SAAS,EAAS,EAAK,EAAM,CAAC,IAAI,EAAW,OAAO,SAAS,GAAG,EAAK,CAAC,IAAM,EAAQ,KAAS,IAAY,EAAK,MAAM,EAAQ,EAAK,CAAC,EAAW,GAAK,eAAe,EAAW,GAAM,EAAM,GAGrL,SAAwB,EAAiB,EAAM,CAAC,GAAK,CAAC,OAAK;;wEAAuK,WAAS,GAAG,YAAU,UAAU,OAAK,YAAU,OAAO,oBAAkB,GAAG,cAAY,IAAI,mBAAiB,GAAG,oBAAkB,GAAG,kBAAgB,IAAI,EAAY,EAAaC,EAAO,KAAK,CAAO,EAAiBA,EAAO,KAAK,CAAO,EAAS,GAAqB,CAAM,CAAC,EAAe,GAAmBC,EAAS,EAAE,CAAM,CAAC,EAAmB,GAAuBA,EAAS,IAAI,IAAI,CAC3lB,EAAMC,MAAY,CAAuE,IAAM,EAA1D,EAAK,QAAQ,UAAU;;EAAO,CAAC,QAAQ,OAAO;EAAK,CAAgC,MAAM,UAAU,CAAO,EAAgB,EAAE,CAAsY,OAArY,EAAW,SAAS,EAAU,IAAiB,CAAC,IAAM,EAAM,EAAU,MAAM,KAAK,CAAC,EAAM,SAAS,EAAK,IAAY,CAAiB,EAAK,MAAM,IAAI,CAAC,OAAO,GAAM,EAAK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