{"version":3,"file":"WavyText.CJqPygaE.mjs","names":["useRef","useState","useCallback","TextTag","__esmMin","window","te","ne","init_ssg_sandbox_shims","_e","ce","init_npm_react_18_3_1","de","motion","init_framer_motion_DhsWWWsN","addPropertyControls","init_framer_BisrWwwE","ControlType","useIsStaticRenderer","WavyText","props","containerRef","letterOffsets","setLetterOffsets","letterColorIntensities","setLetterColorIntensities","isHovering","setIsHovering","calculatedFontSize","setCalculatedFontSize","isStatic","containerDimensions","setContainerDimensions","resizeObserver","entry","entries","fitWidth","calculateFitSize","containerWidth","tempDiv","fontProps","font","text","textWidth","newFontSize","handleMouseMove","rect","relativeY","normalizedY","letters","newOffsets","newColorIntensities","letterElement","index","letterRect","letterCenterX","mouseX","distance","maxDistance","falloff","maxOffset","handleMouseEnter","handleMouseLeave","fontStyles","restFont","isFillMode","layoutMode","htmlTag","textColor","colorIntensity","letter","hoverColor","smoothness","init_WavyText","init_jsx_runtime"],"sources":["https:/framerusercontent.com/modules/aa12h9zMoQkPDu8zhiiF/4iDTNUXhUN2s835Vi7S1/WavyText.js"],"sourcesContent":["// Interactive text component where each letter follows mouse movement vertically on hover\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useState,useRef,useCallback,useEffect,startTransition}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";import{motion}from\"framer-motion\";/**\n * Wavy Text - Interactive text where letters follow mouse movement\n *\n * @framerIntrinsicWidth 400\n * @framerIntrinsicHeight 100\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function WavyText(props){const{text=\"Hello World\",textColor=\"#000000\",hoverColor=\"#0099FF\",font,maxOffset=30,smoothness=.15,fitWidth=false,layoutMode=\"fit\",htmlTag=\"div\"}=props;const containerRef=useRef(null);const[letterOffsets,setLetterOffsets]=useState([]);const[letterColorIntensities,setLetterColorIntensities]=useState([]);const[isHovering,setIsHovering]=useState(false);const[calculatedFontSize,setCalculatedFontSize]=useState(undefined);const isStatic=useIsStaticRenderer();const[containerDimensions,setContainerDimensions]=useState({width:0,height:0});// Observe container size changes\nuseEffect(()=>{if(!containerRef.current)return;const resizeObserver=new ResizeObserver(entries=>{for(const entry of entries){const{width,height}=entry.contentRect;startTransition(()=>{setContainerDimensions({width,height});});}});resizeObserver.observe(containerRef.current);return()=>{resizeObserver.disconnect();};},[]);// Calculate font size to fit width when fitWidth is enabled\nuseEffect(()=>{if(!fitWidth||!containerRef.current){setCalculatedFontSize(undefined);return;}const calculateFitSize=()=>{if(!containerRef.current)return;const containerWidth=containerRef.current.offsetWidth;if(containerWidth===0)return;// Create a temporary element to measure text width\nconst tempDiv=document.createElement(\"div\");tempDiv.style.position=\"absolute\";tempDiv.style.visibility=\"hidden\";tempDiv.style.whiteSpace=\"nowrap\";tempDiv.style.fontSize=\"100px\"// Base size for calculation\n;// Apply font properties except fontSize\nconst fontProps={...font};delete fontProps.fontSize;Object.assign(tempDiv.style,fontProps);tempDiv.textContent=text;document.body.appendChild(tempDiv);const textWidth=tempDiv.offsetWidth;document.body.removeChild(tempDiv);// Calculate the font size needed to fit the container\nconst scaleFactor=containerWidth/textWidth;const newFontSize=100*scaleFactor*.95// 0.95 for slight padding\n;setCalculatedFontSize(`${newFontSize}px`);};calculateFitSize();// Recalculate on window resize\nwindow.addEventListener(\"resize\",calculateFitSize);return()=>window.removeEventListener(\"resize\",calculateFitSize);},[fitWidth,text,font,containerDimensions]);const handleMouseMove=useCallback(e=>{if(!containerRef.current||isStatic)return;const rect=containerRef.current.getBoundingClientRect();const mouseY=e.clientY-rect.top;const centerY=rect.height/2;// Calculate offset based on distance from center\nconst relativeY=mouseY-centerY;const normalizedY=Math.max(-1,Math.min(1,relativeY/(rect.height/2)));// Create wave effect for each letter based on mouse position\nconst letters=text.split(\"\");const newOffsets=[];const newColorIntensities=[];letters.forEach((_,index)=>{const letterElement=containerRef.current?.children[0]?.children[index];if(!letterElement){newOffsets.push(0);newColorIntensities.push(0);return;}const letterRect=letterElement.getBoundingClientRect();const letterCenterX=letterRect.left+letterRect.width/2-rect.left;const mouseX=e.clientX-rect.left;// Calculate distance from mouse to letter\nconst distance=Math.abs(mouseX-letterCenterX);const maxDistance=rect.width/6;// Apply falloff based on distance\nconst falloff=Math.max(0,1-distance/maxDistance);newOffsets.push(normalizedY*maxOffset*falloff);newColorIntensities.push(falloff);});startTransition(()=>{setLetterOffsets(newOffsets);setLetterColorIntensities(newColorIntensities);});},[text,maxOffset,isStatic]);const handleMouseEnter=useCallback(()=>{startTransition(()=>{setIsHovering(true);});},[]);const handleMouseLeave=useCallback(()=>{startTransition(()=>{setIsHovering(false);setLetterOffsets([]);setLetterColorIntensities([]);});},[]);const letters=text.split(\"\");// Prepare font styles, excluding fontSize when fitWidth is enabled\nconst fontStyles=fitWidth?(()=>{const{fontSize,...restFont}=font;return restFont;})():font;const isFillMode=layoutMode===\"fill\";const TextTag=htmlTag;return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:{display:isFillMode?\"flex\":\"inline-block\",alignItems:isFillMode?\"center\":undefined,justifyContent:isFillMode?\"center\":undefined,position:\"relative\",cursor:\"default\",userSelect:\"none\",width:isFillMode?\"100%\":fitWidth?\"100%\":\"max-content\",height:isFillMode?\"100%\":\"auto\"},onMouseMove:isStatic?undefined:handleMouseMove,onMouseEnter:isStatic?undefined:handleMouseEnter,onMouseLeave:isStatic?undefined:handleMouseLeave,children:/*#__PURE__*/_jsx(TextTag,{style:{display:\"flex\",color:textColor,margin:0,padding:0,...fitWidth&&{justifyContent:\"space-between\",width:\"100%\"},...fontStyles,...fitWidth&&calculatedFontSize&&{fontSize:calculatedFontSize}},children:letters.map((letter,index)=>{const colorIntensity=letterColorIntensities[index]||0;return /*#__PURE__*/_jsx(motion.span,{style:{display:\"inline-block\",whiteSpace:letter===\" \"?\"pre\":\"normal\"},animate:{y:isHovering&&letterOffsets[index]!==undefined?letterOffsets[index]:0,color:isHovering&&colorIntensity>0?`color-mix(in srgb, ${hoverColor} ${colorIntensity*100}%, ${textColor})`:textColor},transition:{type:\"spring\",stiffness:600,damping:30,mass:smoothness*.5},children:letter===\" \"?\"\\xa0\":letter},index);})})});}addPropertyControls(WavyText,{text:{type:ControlType.String,title:\"Text\",defaultValue:\"Hello World\"},htmlTag:{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:\"div\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"},hoverColor:{type:ControlType.Color,title:\"Hover Color\",defaultValue:\"#0099FF\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"40px\",variant:\"Bold\",letterSpacing:\"-0.02em\",lineHeight:\"1em\"}},layoutMode:{type:ControlType.Enum,title:\"Layout\",options:[\"fit\",\"fill\"],optionTitles:[\"Fit\",\"Fill\"],defaultValue:\"fit\",displaySegmentedControl:true},fitWidth:{type:ControlType.Boolean,title:\"Fit Width\",defaultValue:false,enabledTitle:\"100%\",disabledTitle:\"Auto\"},maxOffset:{type:ControlType.Number,title:\"Max Offset\",defaultValue:30,min:0,max:100,step:1,unit:\"px\"},smoothness:{type:ControlType.Number,title:\"Smoothness\",defaultValue:.15,min:.05,max:1,step:.05}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"WavyText\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerIntrinsicHeight\":\"100\",\"framerContractVersion\":\"1\",\"framerIntrinsicWidth\":\"400\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./WavyText.map"],"mappings":"A,mQASG,SAAwBmB,EAAS,EAAM,CAAC,GAA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