{"version":3,"file":"ScrollTextReveal.D00a_ZtM.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/r1CUzfmQTpLYjavyjomX/49juBvcmTkPNL22r8njO/ScrollTextReveal.js"],"sourcesContent":["// ScrollTextReveal component that reveals text on scroll with full customization options\nimport{jsx as _jsx}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\"}=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 center\"]});// 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]);}}// 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]);// Create blur transforms for each word\nconst wordBlurs=words.map((_,index)=>{const startProgress=Math.max(0,index*wordDelay/(words.length*wordDelay+duration));const endProgress=Math.min(1,(index*wordDelay+duration)/(words.length*wordDelay+duration));return useTransform(scrollYProgress,[startProgress,endProgress],[initialBlur,0]);});// Create color transforms for each word\nconst wordColors=words.map((_,index)=>{const startProgress=Math.max(0,index*wordDelay/(words.length*wordDelay+duration));const endProgress=Math.min(1,(index*wordDelay+duration)/(words.length*wordDelay+duration));return useTransform(scrollYProgress,[startProgress,endProgress],[textColor,secondTextColor]);});const isFixedWidth=props?.style&&props.style.width===\"100%\";const isFixedHeight=props?.style&&props.style.height===\"100%\";const TextTag=textTag;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\",...font},children:words.map((word,index)=>{return /*#__PURE__*/_jsx(motion.span,{style:{display:\"inline-block\",filter:isStatic?\"blur(0px)\":useTransform(wordBlurs[index],blur=>`blur(${blur}px)`),color:isStatic?secondTextColor:wordColors[index]},animate:{filter:isStatic?\"blur(0px)\":undefined},transition:{duration:isScrolling?0:duration,ease:easing,delay:delay+index*wordDelay},children:word},index);})})});}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},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:false,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\":{\"framerSupportedLayoutWidth\":\"any\",\"framerSupportedLayoutHeight\":\"auto\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ScrollTextReveal.map"],"mappings":"6QAMG,SAAwB,EAAiB,EAAM,CAAC,GAAK,CAAC,OAAK,kCAAkC,YAAU,UAAU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