{"version":3,"file":"MorphingText.BbGL6l7E.mjs","names":["useRef","useState","useCallback"],"sources":["https:/framerusercontent.com/modules/4PruHtTPlyzuwTEUPDtO/HHvMhrcBUMOAz7AInCMp/MorphingText.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useCallback,useEffect,useRef,useState}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";/**\n\n* Morphing Text Effect\n\n*\n\n* @framerSupportedLayoutWidth any-prefer-fixed\n\n* @framerSupportedLayoutHeight fixed\n\n*/// @framerDisableUnlink\nexport default function MorphingText(props){const{texts=[\"Hello\",\"World\",\"Framer\"],morphTime=1.5,cooldownTime=.5,fontSize=40,fontColor=\"#000000\",font,textAlign=\"center\",verticalAlign=\"middle\",style}=props;const textIndexRef=useRef(0);const morphRef=useRef(0);const cooldownRef=useRef(cooldownTime);const timeRef=useRef(performance.now());const text1Ref=useRef(null);const text2Ref=useRef(null);const rootRef=useRef(null);const[mounted,setMounted]=useState(false);const[isVisible,setIsVisible]=useState(true);const isStaticRenderer=useIsStaticRenderer();useEffect(()=>{setMounted(true);},[]);useEffect(()=>{const root=rootRef.current;if(!root||typeof IntersectionObserver===\"undefined\")return;const observer=new IntersectionObserver(([entry])=>setIsVisible(entry.isIntersecting),{threshold:0});observer.observe(root);return()=>observer.disconnect();},[]);const setStyles=useCallback(fraction=>{const el1=text1Ref.current;const el2=text2Ref.current;if(!el1||!el2)return;const inv=1-fraction;el1.style.filter=`blur(${Math.min(8/inv-8,16)}px)`;el1.style.opacity=`${Math.pow(inv,.4)*100}%`;el2.style.filter=`blur(${Math.min(8/fraction-8,16)}px)`;el2.style.opacity=`${Math.pow(fraction,.4)*100}%`;},[]);const resetToStatic=useCallback(()=>{const el1=text1Ref.current;const el2=text2Ref.current;if(!el1||!el2)return;el1.textContent=texts[textIndexRef.current%texts.length];el2.textContent=texts[(textIndexRef.current+1)%texts.length];el1.style.filter=\"none\";el1.style.opacity=\"1\";el2.style.filter=\"none\";el2.style.opacity=\"0\";},[texts]);useEffect(()=>{if(!mounted)return;resetToStatic();if(isStaticRenderer||!isVisible)return;let frameId;timeRef.current=performance.now();const animate=now=>{frameId=requestAnimationFrame(animate);const dt=(now-timeRef.current)/1e3;timeRef.current=now;if(cooldownRef.current>0){cooldownRef.current-=dt;if(cooldownRef.current<=0){morphRef.current=0;}}else{morphRef.current+=dt;let fraction=morphRef.current/morphTime;if(fraction>=1){fraction=1;cooldownRef.current=cooldownTime;textIndexRef.current++;// Immediate swap to prevent flicker\nresetToStatic();}else{setStyles(fraction);}}};frameId=requestAnimationFrame(animate);return()=>cancelAnimationFrame(frameId);},[mounted,isStaticRenderer,isVisible,morphTime,cooldownTime,setStyles,resetToStatic]);const alignConfig={top:{top:0},middle:{top:\"50%\",transform:\"translateY(-50%)\"},bottom:{bottom:0}}[verticalAlign||\"middle\"];const{fontSize:fontObjFontSize,lineHeight:fontLineHeight,...cleanFont}=font||{};return /*#__PURE__*/_jsxs(\"div\",{ref:rootRef,style:{position:\"relative\",width:\"100%\",textAlign,color:fontColor,...cleanFont,...style},children:[/*#__PURE__*/_jsxs(\"div\",{style:{position:\"absolute\",inset:0,width:\"100%\",height:\"100%\",boxSizing:\"border-box\",filter:\"url(#threshold) blur(0.6px)\",overflow:\"visible\",fontSize:`${fontSize}px`,lineHeight:fontLineHeight},children:[/*#__PURE__*/_jsx(\"span\",{ref:text1Ref,style:{position:\"absolute\",left:0,width:\"100%\",whiteSpace:\"pre-wrap\",overflowWrap:\"break-word\",wordBreak:\"break-word\",opacity:1,...alignConfig},children:texts[0]}),/*#__PURE__*/_jsx(\"span\",{ref:text2Ref,style:{position:\"absolute\",left:0,width:\"100%\",height:\"max-content\",whiteSpace:\"pre-wrap\",overflowWrap:\"break-word\",wordBreak:\"break-word\",opacity:0,...alignConfig},children:texts[1]||texts[0]})]}),/*#__PURE__*/_jsx(\"svg\",{style:{position:\"absolute\",height:0,width:0,visibility:\"hidden\"},\"aria-hidden\":\"true\",children:/*#__PURE__*/_jsx(\"defs\",{children:/*#__PURE__*/_jsx(\"filter\",{id:\"threshold\",children:/*#__PURE__*/_jsx(\"feColorMatrix\",{in:\"SourceGraphic\",type:\"matrix\",values:\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 255 -140\"})})})})]});}addPropertyControls(MorphingText,{texts:{type:ControlType.Array,title:\"Texts\",control:{type:ControlType.String},defaultValue:[\"Hello\",\"World\",\"Framer\"],maxCount:10},morphTime:{type:ControlType.Number,title:\"Morph Time\",defaultValue:1.5,min:.1,max:5,step:.1,displayStepper:true},cooldownTime:{type:ControlType.Number,title:\"Cooldown Time\",defaultValue:.5,min:.1,max:3,step:.1,displayStepper:true},fontSize:{type:ControlType.Number,title:\"Font Size\",defaultValue:40,min:10,max:100},fontColor:{type:ControlType.Color,title:\"Font Color\",defaultValue:\"#000000\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultValue:{variant:\"Bold\",lineHeight:\"1em\"}},textAlign:{type:ControlType.Enum,title:\"Text Align\",options:[\"left\",\"center\",\"right\"],defaultValue:\"center\"},verticalAlign:{type:ControlType.Enum,title:\"Vertical Align\",description:\"Created By [THE DESIGN FUTURIST](https://thedesignfuturist.zip)\",options:[\"top\",\"middle\",\"bottom\"],defaultValue:\"middle\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"MorphingText\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"fixed\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerDisableUnlink\":\"\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./MorphingText.map"],"mappings":"8MAWA,SAAwB,EAAa,EAAM,CAAC,GAAK,CAAC,QAAM,CAAC,QAAQ,QAAQ,QAAQ,EAAE,YAAU,IAAI,eAAa,GAAG,WAAS,GAAG,YAAU,UAAU,OAAK,YAAU,SAA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