{"version":3,"file":"StaggeredText.DXjQHMb_.mjs","names":["useState","useRef","useMemo","paragraphs","p","currentWordIndex"],"sources":["https:/framerusercontent.com/modules/J3CpiecFvZkDLmCONZuv/9Xz2ajYcel1TlNnAm6y6/StaggeredText.js"],"sourcesContent":["// Text appear component with staggered word animation, each word slides up from below\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import React from\"react\";import{useEffect,useRef,useState,useMemo}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer,RenderTarget}from\"framer\";import{useInView}from\"framer-motion\";/**\n * Staggered Text Appear\n * @framerDisableUnlink\n *\n * @framerIntrinsicWidth 400\n * @framerIntrinsicHeight 60\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight auto\n */function StaggeredText(props){const{text,delay,duration,color,font,style,tag,textIndent=0,shiftBlock=false,initialDelay=0,staggerBy=\"words\",animate=true,disableForSafari=true,paragraphGap=0}=props;const isStatic=useIsStaticRenderer();const[visible,setVisible]=useState(false);const[lineIndices,setLineIndices]=useState([]);const ref=useRef(null);const wordRefs=useRef([]);const inView=useInView(ref,{once:true,margin:\"-10% 0px\"});// Detect Safari browser\nconst isSafari=useMemo(()=>{if(typeof window===\"undefined\")return false;const ua=window.navigator.userAgent;return/^((?!chrome|android).)*safari/i.test(ua);},[]);// Disable animation for Safari\nconst shouldUseAnimation=animate&&!(isSafari&&disableForSafari);const{paragraphs,items}=useMemo(()=>{const paragraphs=text.split(\"\\n\").filter(p=>p.trim());if(staggerBy===\"symbols\"){const allItems=paragraphs.map(para=>para.trim().split(/\\s+/).map(word=>word.split(\"\")));return{paragraphs,items:allItems};}const allItems=paragraphs.map(para=>para.trim().split(/\\s+/));return{paragraphs,items:allItems};},[text,staggerBy]);useEffect(()=>{if(staggerBy!==\"lines\"||!ref.current)return;const measureLines=()=>{const positions=wordRefs.current.map(el=>{if(!el)return 0;return el.getBoundingClientRect().top;});const lines=[];let currentLine=0;let currentTop=positions[0];positions.forEach((top,i)=>{if(Math.abs(top-currentTop)>5){currentLine++;currentTop=top;}lines[i]=currentLine;});setLineIndices(lines);};measureLines();window.addEventListener(\"resize\",measureLines);return()=>window.removeEventListener(\"resize\",measureLines);},[staggerBy,items,font,textIndent]);useEffect(()=>{if(isStatic||RenderTarget.current()!==RenderTarget.preview)return;if(inView){const timeout=setTimeout(()=>{setVisible(true);},initialDelay);return()=>clearTimeout(timeout);}},[isStatic,inView,initialDelay]);const shouldAnimate=shouldUseAnimation&&(visible||isStatic||RenderTarget.current()!==RenderTarget.preview);const justifyContent=font.textAlign===\"center\"?\"center\":font.textAlign===\"right\"?\"flex-end\":\"flex-start\";const baseStyle={...style,color,...font,width:\"100%\",minWidth:0,margin:0,padding:0,transform:shiftBlock&&textIndent>0?`translateX(-${textIndent}px)`:undefined};// If animation is off, render as simple text block\nif(!shouldUseAnimation){return /*#__PURE__*/React.createElement(tag,{style:{...baseStyle,textIndent:textIndent>0?`${textIndent}px`:0,whiteSpace:\"pre-wrap\"}},text);}let symbolIndex=0;let wordIndex=0;return /*#__PURE__*/React.createElement(tag,{ref,style:{...baseStyle,display:\"flex\",flexDirection:\"column\",gap:paragraphGap}},items.map((paragraphItems,paraIndex)=>{return /*#__PURE__*/React.createElement(\"span\",{key:paraIndex,style:{display:\"flex\",flexWrap:\"wrap\",alignItems:\"flex-end\",justifyContent,width:\"100%\"}},paragraphItems.map((item,itemIndex)=>{if(staggerBy===\"symbols\"){const wordSymbols=item.map((symbol,symbolIndexInWord)=>{const currentSymbolIndex=symbolIndex++;return /*#__PURE__*/_jsx(\"span\",{style:{display:\"inline-block\",verticalAlign:\"bottom\"},children:/*#__PURE__*/_jsx(\"span\",{style:{display:\"inline-block\",transform:shouldAnimate?\"translateY(0%)\":\"translateY(100%)\",transition:`transform ${duration}ms cubic-bezier(.4,1,.4,1) ${currentSymbolIndex*delay}ms`,willChange:\"transform\",whiteSpace:\"pre\"},children:symbol})},symbolIndexInWord);});const currentWordIndex=wordIndex++;return /*#__PURE__*/_jsxs(\"span\",{ref:el=>wordRefs.current[currentWordIndex]=el,style:{display:\"inline-flex\",overflow:\"hidden\",marginLeft:paraIndex===0&&itemIndex===0&&textIndent>0?textIndent:0,paddingRight:font.letterSpacing&&parseFloat(font.letterSpacing)<0?`${Math.abs(parseFloat(font.letterSpacing))}em`:0},children:[wordSymbols,itemIndex<paragraphItems.length-1&&/*#__PURE__*/_jsx(\"span\",{style:{whiteSpace:\"pre\"},children:\" \"})]},itemIndex);}const displayText=item+(itemIndex<paragraphItems.length-1?\" \":\"\");const currentWordIndex=wordIndex++;const itemDelay=staggerBy===\"lines\"?(lineIndices[currentWordIndex]||0)*delay:currentWordIndex*delay;return /*#__PURE__*/_jsx(\"span\",{ref:el=>wordRefs.current[currentWordIndex]=el,style:{display:\"inline-block\",overflow:\"hidden\",verticalAlign:\"bottom\"},children:/*#__PURE__*/_jsx(\"span\",{style:{display:\"inline-block\",transform:shouldAnimate?\"translateY(0%)\":\"translateY(100%)\",transition:`transform ${duration}ms cubic-bezier(.4,1,.4,1) ${itemDelay}ms`,willChange:\"transform\",whiteSpace:\"pre\",marginLeft:paraIndex===0&&itemIndex===0&&textIndent>0?textIndent:0},children:displayText})},itemIndex);}));}));}addPropertyControls(StaggeredText,{text:{type:ControlType.String,title:\"Text\",defaultValue:\"Staggered text appear animation\",displayTextArea:true},animate:{type:ControlType.Boolean,title:\"Animate\",defaultValue:true,enabledTitle:\"On\",disabledTitle:\"Off\"},staggerBy:{type:ControlType.Enum,title:\"Stagger By\",options:[\"symbols\",\"words\",\"lines\"],optionTitles:[\"Symbols\",\"Words\",\"Lines\"],defaultValue:\"words\"},duration:{type:ControlType.Number,title:\"Duration\",defaultValue:400,min:100,max:2e3,unit:\"ms\",step:50},initialDelay:{type:ControlType.Number,title:\"Delay\",defaultValue:0,min:0,max:2e3,unit:\"ms\",step:10},delay:{type:ControlType.Number,title:\"Stagger\",defaultValue:80,min:0,max:1e3,unit:\"ms\",step:10},color:{type:ControlType.Color,title:\"Color\",defaultValue:\"#000000\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"32px\",variant:\"Semibold\",letterSpacing:\"-0.01em\",lineHeight:\"1.2em\"}},tag:{type:ControlType.Enum,title:\"Tag\",options:[\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"p\",\"span\"],optionTitles:[\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"p\",\"span\"],defaultValue:\"h2\"},textIndent:{type:ControlType.Number,title:\"Text Indent\",defaultValue:0,min:0,max:800,unit:\"px\",step:1},shiftBlock:{type:ControlType.Boolean,title:\"Shift Block\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"},disableForSafari:{type:ControlType.Boolean,title:\"Disable for Safari\",defaultValue:true,enabledTitle:\"On\",disabledTitle:\"Off\"},paragraphGap:{type:ControlType.Number,title:\"Paragraph\",defaultValue:0,min:0,max:200,unit:\"px\",step:1,description:\"Component made by Anton Drukarov\"}});export default StaggeredText;\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"StaggeredText\",\"slots\":[],\"annotations\":{\"framerIntrinsicWidth\":\"400\",\"framerIntrinsicHeight\":\"60\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"auto\",\"framerDisableUnlink\":\"*\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./StaggeredText.map"],"mappings":"kRAUG,SAAS,EAAc,EAAM,CAAC,GAAK,CAAC,OAAK,QAAM,WAAS,QAAM,OAAK,QAAM,MAAI,aAAW,EAAE,aAAW,GAAM,eAAa,EAAE,YAAU,QAAQ,UAAQ,GAAK,mBAAiB,GAAK,eAAa,GAAG,EAAY,EAAS,GAAqB,CAAM,CAAC,EAAQ,GAAYA,EAAS,GAAM,CAAM,CAAC,EAAY,GAAgBA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