{"version":3,"file":"ScrollTextReveal_1.CMR1hxuo.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/CEMXvsKYhZFaZjS9Aavb/SJYB6HHr6gyDoo7sYaMq/ScrollTextReveal_1.js"],"sourcesContent":["// ScrollTextReveal component that reveals text on scroll with full customization options\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useRef,useEffect,useState}from\"react\";import{motion,useScroll,useTransform}from\"framer-motion\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";/**\n * ScrollTextReveal component that reveals text on scroll with full customization options\n *\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight auto\n */export default function ScrollTextReveal(props){const{text=\"Your text will reveal on scroll\",textColor=\"#000000\",secondTextColor=\"#000000\",font,initialBlur=10,duration=.8,easing=\"easeOut\",delay=0,wordDelay=.1,textBalance=false,textTag=\"p\",revealByLetter=false,uppercase=false,triggerPosition=.8}=props;const ref=useRef(null);const isStatic=useIsStaticRenderer();const[lastScrollY,setLastScrollY]=useState(0);const[isScrolling,setIsScrolling]=useState(false);const[scrollTimeout,setScrollTimeout]=useState(null);// Use scroll-based animation\nconst{scrollYProgress}=useScroll({target:ref,offset:[\"start end\",`center ${triggerPosition}`]});// Split text into words\n// Fix: Remove leading spaces from lines and append to previous word\nconst wordsRaw=text.split(/(\\s+)/);const words=[];for(let i=0;i<wordsRaw.length;i++){if(/^\\s+$/.test(wordsRaw[i])&&i>0){words[words.length-1]+=wordsRaw[i];}else if(!/^\\s+$/.test(wordsRaw[i])){words.push(wordsRaw[i]);}}// Process words into structured data\nconst wordGroups=revealByLetter?words.map(word=>{// Separate trailing spaces from the word\nconst match=word.match(/^(\\S+)(\\s*)$/);if(match){const[,wordPart,spacePart]=match;return{letters:wordPart.split(\"\"),trailingSpace:spacePart};}return{letters:word.split(\"\"),trailingSpace:\"\"};}):words.map(word=>({letters:[word],trailingSpace:\"\"}));// Calculate total elements for animation timing\nconst totalElements=revealByLetter?wordGroups.reduce((sum,group)=>sum+group.letters.length,0):wordGroups.length;// Track scroll movement to detect when scrolling stops\nuseEffect(()=>{if(isStatic)return;const handleScroll=()=>{const currentScrollY=window.scrollY;if(currentScrollY!==lastScrollY){setIsScrolling(true);setLastScrollY(currentScrollY);// Clear existing timeout\nif(scrollTimeout){clearTimeout(scrollTimeout);}// Set new timeout to detect when scrolling stops\nconst newTimeout=window.setTimeout(()=>{setIsScrolling(false);},150)// 150ms delay to detect scroll stop\n;setScrollTimeout(newTimeout);}};window.addEventListener(\"scroll\",handleScroll,{passive:true});return()=>{window.removeEventListener(\"scroll\",handleScroll);if(scrollTimeout){clearTimeout(scrollTimeout);}};},[lastScrollY,scrollTimeout,isStatic]);const isFixedWidth=props?.style&&props.style.width===\"100%\";const isFixedHeight=props?.style&&props.style.height===\"100%\";const TextTag=textTag;// Track element index across all words\nlet elementIndex=0;return /*#__PURE__*/_jsx(motion.div,{ref:ref,style:{...props.style,position:\"relative\",width:isFixedWidth?\"100%\":\"100%\",height:isFixedHeight?\"100%\":\"auto\",display:\"flex\",alignItems:\"flex-start\",justifyContent:\"flex-start\"},children:/*#__PURE__*/_jsx(TextTag,{style:{width:\"100%\",margin:0,padding:0,wordBreak:\"break-word\",overflowWrap:\"break-word\",whiteSpace:\"pre-wrap\",textWrap:textBalance?\"balance\":\"auto\",textTransform:uppercase?\"uppercase\":\"none\",...font},children:wordGroups.map((wordGroup,wordIndex)=>{return /*#__PURE__*/_jsxs(\"span\",{style:{display:\"inline-block\",whiteSpace:\"nowrap\"},children:[wordGroup.letters.map((letter,letterIndex)=>{const currentIndex=elementIndex++;const startProgress=Math.max(0,currentIndex*wordDelay/(totalElements*wordDelay+duration));const endProgress=Math.min(1,(currentIndex*wordDelay+duration)/(totalElements*wordDelay+duration));const blur=useTransform(scrollYProgress,[startProgress,endProgress],[initialBlur,0]);const color=useTransform(scrollYProgress,[startProgress,endProgress],[textColor,secondTextColor]);return /*#__PURE__*/_jsx(motion.span,{style:{display:\"inline-block\",filter:isStatic?\"blur(0px)\":useTransform(blur,b=>`blur(${b}px)`),color:isStatic?secondTextColor:color},animate:{filter:isStatic?\"blur(0px)\":undefined},transition:{duration:isScrolling?0:duration,ease:easing,delay:delay+currentIndex*wordDelay},children:letter},letterIndex);}),wordGroup.trailingSpace&&/*#__PURE__*/_jsx(\"span\",{dangerouslySetInnerHTML:{__html:wordGroup.trailingSpace.replace(/ /g,\"&nbsp;\")}})]},wordIndex);})})});}addPropertyControls(ScrollTextReveal,{text:{type:ControlType.String,title:\"Text Content\",defaultValue:\"Your text will reveal on scroll\",displayTextArea:true},textTag:{type:ControlType.Enum,title:\"HTML Tag\",options:[\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"p\",\"span\",\"div\"],optionTitles:[\"H1\",\"H2\",\"H3\",\"H4\",\"H5\",\"H6\",\"Paragraph\",\"Span\",\"Div\"],defaultValue:\"p\",displaySegmentedControl:false},revealByLetter:{type:ControlType.Boolean,title:\"Reveal Mode\",defaultValue:false,enabledTitle:\"By Letter\",disabledTitle:\"By Word\"},uppercase:{type:ControlType.Boolean,title:\"Uppercase\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"},triggerPosition:{type:ControlType.Number,title:\"Viewport Start\",defaultValue:.8,min:0,max:1,step:.05,displayStepper:true,description:\"Controls when animation starts (0 = top, 1 = bottom of viewport)\"},textColor:{type:ControlType.Color,title:\"Initial Color\",defaultValue:\"#000000\"},secondTextColor:{type:ControlType.Color,title:\"Final Color\",defaultValue:\"#000000\"},font:{type:ControlType.Font,title:\"Font\",defaultValue:{fontSize:\"32px\",variant:\"Semibold\",letterSpacing:\"-0.03em\",lineHeight:\"1.2em\"},controls:\"extended\",defaultFontType:\"sans-serif\"},textBalance:{type:ControlType.Boolean,title:\"Text Balance\",defaultValue:true,enabledTitle:\"Balance\",disabledTitle:\"Auto\"},initialBlur:{type:ControlType.Number,title:\"Initial Blur\",defaultValue:10,min:0,max:50,step:.1},duration:{type:ControlType.Number,title:\"Animation Duration\",defaultValue:.8,min:.1,max:3,step:.1,unit:\"s\"},easing:{type:ControlType.Enum,title:\"Easing\",options:[\"linear\",\"easeIn\",\"easeOut\",\"easeInOut\",\"circIn\",\"circOut\",\"circInOut\",\"backIn\",\"backOut\",\"backInOut\"],optionTitles:[\"Linear\",\"Ease In\",\"Ease Out\",\"Ease In Out\",\"Circ In\",\"Circ Out\",\"Circ In Out\",\"Back In\",\"Back Out\",\"Back In Out\"],defaultValue:\"easeOut\"},delay:{type:ControlType.Number,title:\"Animation Delay\",defaultValue:0,min:0,max:2,step:.1,unit:\"s\"},wordDelay:{type:ControlType.Number,title:\"Word Delay\",defaultValue:.1,min:0,max:2,step:.1,unit:\"s\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ScrollTextReveal\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"auto\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ScrollTextReveal_1.map"],"mappings":"oRAMG,SAAwB,EAAiB,EAAM,CAAC,GAAK,CAAC,OAAK,kCAAkC,YAAU,UAAU,kBAAgB,UAAU,OAAK,cAAY,GAAG,WAAS,GAAG,SAAO,UAAU,QAAM,EAAE,YAAU,GAAG,cAAY,GAAM,UAAQ,IAAI,iBAAe,GAAM,YAAU,GAAM,kBAAgB,IAAI,EAAY,EAAIA,EAAO,IAAI,EAAQ,EAAS,EAAoB,EAAO,CAAC,EAAY,GAAgBC,EAAS,CAAC,EAAO,CAAC,EAAY,GAAgBA,EAAS,EAAK,EAAO,CAAC,EAAc,GAAkBA,EAAS,IAAI,EAC3f,CAAC,mBAAiB,EAAU,CAAC,OAAO,EAAI,OAAO,CAAC,YAAY,UAAU,GAAiB,CAAC,CAAC,EAExF,EAAS,EAAK,MAAM,OAAO,EAAQ,EAAM,CAAC,EAAE,IAAI,IAAI,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