{"version":3,"file":"ScrollTextReveal.BzpTM9aI.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/hDchxhvSnhJWn04Xo15z/YmIn9FlySYE1zR5tDzE5/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\",font,initialOpacity=0,triggerPoint=\"center\",duration=.8,easing=\"easeOut\",delay=0,wordDelay=.1,textBalance=\"auto\"}=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:triggerPoint===\"top\"?[\"start end\",\"start center\"]:triggerPoint===\"center\"?[\"start end\",\"center center\"]:[\"start end\",\"end 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 opacity transforms for each word\nconst wordOpacities=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],[initialOpacity,1]);});const isFixedWidth=props?.style&&props.style.width===\"100%\";const isFixedHeight=props?.style&&props.style.height===\"100%\";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(\"span\",{style:{width:\"100%\",color:textColor,margin:0,padding:0,wordBreak:\"break-word\",overflowWrap:\"break-word\",whiteSpace:\"pre-wrap\",textWrap:textBalance===\"balance\"?\"balance\":undefined,...font},children:words.map((word,index)=>{return /*#__PURE__*/_jsx(motion.span,{style:{display:\"inline-block\",opacity:isStatic?1:wordOpacities[index]},animate:{opacity:isStatic?1: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},textColor:{type:ControlType.Color,title:\"Text 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.Enum,title:\"Text Balance\",options:[\"auto\",\"balance\",\"stable\",\"pretty\"],optionTitles:[\"Auto\",\"Balance\",\"Stable\",\"Pretty\"],defaultValue:\"auto\"},initialOpacity:{type:ControlType.Number,title:\"Initial Opacity\",defaultValue:0,min:0,max:1,step:.1},triggerPoint:{type:ControlType.Enum,title:\"Trigger Point\",options:[\"top\",\"center\",\"bottom\"],optionTitles:[\"Top of Element\",\"Center of Element\",\"Bottom of Element\"],defaultValue:\"center\",displaySegmentedControl:true},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.map"],"mappings":"6QAMG,SAAwB,EAAiB,EAAM,CAAC,GAAK,CAAC,OAAK,kCAAkC,YAAU,UAAU,OAAK,iBAAe,EAAE,eAAa,SAAS,WAAS,GAAG,SAAO,UAAU,QAAM,EAAE,YAAU,GAAG,cAAY,QAAQ,EAAY,EAAIA,EAAO,IAAI,EAAQ,EAAS,EAAoB,EAAO,CAAC,EAAY,GAAgBC,EAAS,CAAC,EAAO,CAAC,EAAY,GAAgBA,EAAS,EAAK,EAAO,CAAC,EAAc,GAAkBA,E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