{"version":3,"file":"CurvedLoopText.DTkZ3ffq.mjs","names":["useRef","useState","useCallback","startTransition"],"sources":["https:/framerusercontent.com/modules/c2jaMn5AakjXy6UHe86J/7WNTllC3dOMfLZNjBYhr/CurvedLoopText.js"],"sourcesContent":["// Animated curved text marquee component that loops smoothly along straight or curved paths,\n// with speed control, drag interaction, and full typography customization\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useRef,useState,useCallback,startTransition}from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";import{motion,useMotionValue,useSpring,animate}from\"framer-motion\";/**\n * Animated Curved Loop Text\n *\n * @framerIntrinsicWidth 800\n * @framerIntrinsicHeight 200\n *\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight fixed\n */export default function CurvedLoopText(props){const{text=\"Curved Loop Text • Animated Marquee • \",ariaLabel=\"\",speed=50,direction=\"left\",curveIntensity=50,pathType=\"curved\",font,textColor=\"#000000\",hoverTextColor=\"#FF0000\",backgroundColor=\"#FFFFFF\",enableDrag=true,paused=false,interactionType=\"hover\",style}=props;const containerRef=useRef(null);const svgRef=useRef(null);const textPathRefs=useRef([null,null,null]);const[textWidth,setTextWidth]=useState(0);const[containerWidth,setContainerWidth]=useState(800);const[containerHeight,setContainerHeight]=useState(200);const[isHovering,setIsHovering]=useState(false);const[isClicked,setIsClicked]=useState(false);const offset=useMotionValue(0);const dragOffset=useMotionValue(0);const springOffset=useSpring(dragOffset,{stiffness:300,damping:30});const isDragging=useRef(false);const lastDragX=useRef(0);const dragVelocity=useRef(0);const animationRef=useRef(null);const runCycleRef=useRef(()=>{});const isStatic=RenderTarget.current()===RenderTarget.thumbnail;const isHoveringRef=useRef(isHovering);const textWidthRef=useRef(textWidth);const containerWidthRef=useRef(containerWidth);useEffect(()=>{isHoveringRef.current=isHovering;},[isHovering]);useEffect(()=>{textWidthRef.current=textWidth;},[textWidth]);useEffect(()=>{containerWidthRef.current=containerWidth;},[containerWidth]);useEffect(()=>{if(typeof window===\"undefined\")return;const measureText=()=>{const tempSvg=document.createElementNS(\"http://www.w3.org/2000/svg\",\"svg\");tempSvg.style.position=\"absolute\";tempSvg.style.visibility=\"hidden\";document.body.appendChild(tempSvg);const tempText=document.createElementNS(\"http://www.w3.org/2000/svg\",\"text\");tempText.textContent=text;tempText.style.fontSize=font?.fontSize||\"48px\";tempText.style.fontWeight=font?.fontWeight||\"700\";tempText.style.fontFamily=font?.fontFamily||\"inherit\";tempText.style.letterSpacing=font?.letterSpacing||\"0px\";tempSvg.appendChild(tempText);const bbox=tempText.getBBox();document.body.removeChild(tempSvg);startTransition(()=>setTextWidth(bbox.width));};measureText();},[text,font]);useEffect(()=>{if(!containerRef.current)return;const updateDimensions=()=>{const rect=containerRef.current?.getBoundingClientRect();if(rect){startTransition(()=>{setContainerWidth(rect.width);setContainerHeight(rect.height);});}};updateDimensions();if(typeof window!==\"undefined\"){window.addEventListener(\"resize\",updateDimensions);return()=>window.removeEventListener(\"resize\",updateDimensions);}},[]);useEffect(()=>{const unsubscribe=offset.on(\"change\",latest=>{const tw=textWidthRef.current;const cw=containerWidthRef.current;if(tw===0||cw===0)return;textPathRefs.current.forEach((el,i)=>{if(el){el.setAttribute(\"startOffset\",`${(latest+i*tw)/cw*100}%`);}});});return unsubscribe;},[offset]);useEffect(()=>{if(isStatic||paused||textWidth===0)return;const runCycle=()=>{const tw=textWidth;const pos=offset.get();const effectiveSpeed=isHoveringRef.current?speed*.3:speed;let normalised;if(direction===\"left\"){normalised=-((-pos%tw+tw)%tw);}else{normalised=(pos%tw+tw)%tw;}offset.set(normalised);const duration=tw/effectiveSpeed*10;const target=direction===\"left\"?normalised-tw:normalised+tw;animationRef.current=animate(offset,target,{duration,ease:\"linear\",onComplete:runCycle});};runCycleRef.current=runCycle;runCycle();return()=>{animationRef.current?.stop();};},[speed,direction,textWidth,paused,isStatic,isHovering]);const handleMouseDown=useCallback(e=>{if(interactionType===\"click\"){startTransition(()=>setIsClicked(prev=>!prev));}if(!enableDrag||isStatic)return;e.preventDefault();isDragging.current=true;lastDragX.current=e.clientX;dragVelocity.current=0;animationRef.current?.stop();},[enableDrag,isStatic,interactionType]);const handleMouseMove=useCallback(e=>{if(!isDragging.current||!enableDrag)return;const deltaX=e.clientX-lastDragX.current;dragVelocity.current=deltaX;lastDragX.current=e.clientX;offset.set(offset.get()+deltaX*2);dragOffset.set(deltaX);},[enableDrag,offset,dragOffset]);const handleMouseUp=useCallback(()=>{if(!isDragging.current)return;isDragging.current=false;dragOffset.set(0);if(!paused){runCycleRef.current?.();}},[paused,dragOffset]);useEffect(()=>{if(typeof window===\"undefined\"||isStatic)return;window.addEventListener(\"mousemove\",handleMouseMove);window.addEventListener(\"mouseup\",handleMouseUp);return()=>{window.removeEventListener(\"mousemove\",handleMouseMove);window.removeEventListener(\"mouseup\",handleMouseUp);};},[handleMouseMove,handleMouseUp,isStatic]);const pathD=pathType===\"curved\"?`M 0,${containerHeight/2} Q ${containerWidth/2},${containerHeight/2-curveIntensity} ${containerWidth},${containerHeight/2}`:`M 0,${containerHeight/2} L ${containerWidth},${containerHeight/2}`;const isEffectActive=interactionType===\"hover\"?isHovering:isClicked;// Derive a clean accessible label:\n// If ariaLabel is set use it; otherwise strip bullet separators from the\n// looping text so screen readers don't read \"WHO WE ARE • WHO WE ARE • …\"\nconst resolvedAriaLabel=ariaLabel.trim()||text.replace(/\\s*•\\s*/g,\" \").trim();return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,// aria-label gives screen readers and Google a clean single reading\n// of the content. aria-roledescription clarifies it's a marquee.\n\"aria-label\":resolvedAriaLabel,role:\"img\",style:{...style,width:\"100%\",height:\"100%\",backgroundColor,overflow:\"hidden\",cursor:enableDrag?isDragging.current?\"grabbing\":\"grab\":\"default\",userSelect:\"none\",position:\"relative\"},onMouseDown:handleMouseDown,onMouseEnter:()=>startTransition(()=>setIsHovering(true)),onMouseLeave:()=>startTransition(()=>setIsHovering(false)),children:/*#__PURE__*/_jsxs(motion.svg,{ref:svgRef,\"aria-hidden\":\"true\",width:\"100%\",height:\"100%\",viewBox:`0 0 ${containerWidth} ${containerHeight}`,style:{position:\"absolute\",top:0,left:0},children:[/*#__PURE__*/_jsx(\"defs\",{children:/*#__PURE__*/_jsx(\"path\",{id:\"textPath\",d:pathD})}),[0,1,2].map(index=>/*#__PURE__*/_jsx(motion.text,{fill:isEffectActive?hoverTextColor:textColor,style:{dominantBaseline:\"middle\",fontSize:font?.fontSize,fontWeight:font?.fontWeight,fontFamily:font?.fontFamily,fontStyle:font?.fontStyle,letterSpacing:font?.letterSpacing},children:/*#__PURE__*/_jsx(\"textPath\",{ref:el=>{textPathRefs.current[index]=el;},href:\"#textPath\",startOffset:\"0%\",children:text})},index))]})});}addPropertyControls(CurvedLoopText,{ariaLabel:{type:ControlType.String,title:\"Aria Label\",defaultValue:\"\",placeholder:\"e.g. Who We Are\",description:\"A short, clean description read by screen readers and Google instead of the repetitive looping text. If left blank, bullet separators are stripped from the text automatically.\"},text:{type:ControlType.String,title:\"Text\",defaultValue:\"Curved Loop Text • Animated Marquee • \"},speed:{type:ControlType.Number,title:\"Speed\",defaultValue:50,min:10,max:200,step:5},direction:{type:ControlType.Enum,title:\"Direction\",options:[\"left\",\"right\"],optionTitles:[\"Left\",\"Right\"],defaultValue:\"left\",displaySegmentedControl:true},pathType:{type:ControlType.Enum,title:\"Path Type\",options:[\"curved\",\"straight\"],optionTitles:[\"Curved\",\"Straight\"],defaultValue:\"curved\",displaySegmentedControl:true},curveIntensity:{type:ControlType.Number,title:\"Curve Intensity\",defaultValue:50,min:0,max:150,step:5,hidden:({pathType})=>pathType===\"straight\"},interactionType:{type:ControlType.Enum,title:\"Interaction\",options:[\"hover\",\"click\"],optionTitles:[\"Hover\",\"Click\"],defaultValue:\"hover\",displaySegmentedControl:true},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"48px\",variant:\"Bold\",letterSpacing:\"0px\"}},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"},hoverTextColor:{type:ControlType.Color,title:\"Hover Text Color\",defaultValue:\"#FF0000\"},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#FFFFFF\"},enableDrag:{type:ControlType.Boolean,title:\"Enable Drag\",defaultValue:true,enabledTitle:\"On\",disabledTitle:\"Off\"},paused:{type:ControlType.Boolean,title:\"Paused\",defaultValue:false,enabledTitle:\"Yes\",disabledTitle:\"No\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CurvedLoopText\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"fixed\",\"framerIntrinsicHeight\":\"200\",\"framerIntrinsicWidth\":\"800\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CurvedLoopText.map"],"mappings":"ySAUG,SAAwB,EAAe,EAAM,CAAC,GAAK,CAAC,OAAK,yCAAyC,YAAU,GAAG,QAAM,GAAG,YAAU,OAAO,iBAAe,GAAG,WAAS,SAAS,OAAK,YAAU,UAAU,iBAAe,UAAU,kBAAgB,UAAU,aAAW,GAAK,SAAO,GAAM,kBAAgB,QAAQ,SAAO,EAAY,EAAaA,EAAO,KAAK,CAAO,EAAOA,EAAO,KAAK,CAAO,EAAaA,EAAO,CAAC,KAAK,KAAK,KAAK,CAAC,CAAM,CAAC,EAAU,GAAcC,EAAS,EAAE,CAAM,CAAC,EAAe,GAAmBA,EAAS,IAAI,CAAM,CAAC,EAAgB,GAAoBA,EAAS,IAAI,CAAM,CAAC,EAAW,GAAeA,EAAS,GAAM,CAAM,CAAC,EAAU,GAAcA,EAAS,GAAM,CAAO,EAAO,EAAe,EAAE,CAAO,EAAW,EAAe,EAAE,CAAoB,EAAU,EAAW,CAAC,UAAU,IAAI,QAAQ,GAAG,CAAC,CAAC,IAAM,EAAWD,EAAO,GA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