{"version":3,"file":"ScrollingTextPath.Dn3EqXYm.mjs","names":["useRef","useState","useCallback","useMemo"],"sources":["https:/framerusercontent.com/modules/pf0EqeSJ8mVaLdle1NQY/FAHHbO0tKslLew6K0snE/ScrollingTextPath.js"],"sourcesContent":["// Section moderne avec texte suivant un path SVG ondulé, animé au scroll\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useRef,useMemo,useState,useEffect,useCallback}from\"react\";import{motion,useScroll,useTransform}from\"framer-motion\";import{addPropertyControls,ControlType}from\"framer\";/**\n * Wavy Scroll Text\n *\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight auto\n */export default function ScrollingTextPath(props){const{text=\"Animated text along a path! 👀\",backgroundColor=\"#5a7a6a\",pathColor=\"#f5c2d6\",textColor=\"#000000\",pathWidth=120,scrollSpeed=1,pathCurve=1,textFont,textSpacing=20,blockHeight=400}=props;const containerRef=useRef(null);const[containerWidth,setContainerWidth]=useState(1e3);const updateWidth=useCallback(()=>{if(containerRef.current){setContainerWidth(containerRef.current.offsetWidth);}},[]);useEffect(()=>{if(typeof window===\"undefined\")return;updateWidth();window.addEventListener(\"resize\",updateWidth);return()=>window.removeEventListener(\"resize\",updateWidth);},[updateWidth]);const{scrollYProgress}=useScroll({target:containerRef,offset:[\"start end\",\"end start\"]});const isMobile=useMemo(()=>containerWidth<768,[containerWidth]);const pathConfig=useMemo(()=>({length:isMobile?2e3:3e3,width:isMobile?pathWidth*.7:pathWidth,amplitude:(isMobile?150:200)*pathCurve,frequency:.003}),[isMobile,pathWidth,pathCurve]);const responsiveFontSize=useMemo(()=>{const baseFontSize=parseFloat(textFont?.fontSize)||48;return isMobile?Math.max(baseFontSize*.5,24):baseFontSize;},[textFont?.fontSize,isMobile]);const textOffset=useTransform(scrollYProgress,[0,1],[0,-pathConfig.length*scrollSpeed]);const svgPath=useMemo(()=>{const{length,amplitude,frequency,width}=pathConfig;const points=[`M 0 ${amplitude+width/2}`];for(let x=0;x<=length;x+=10){const y=Math.sin(x*frequency)*amplitude+amplitude+width/2;points.push(`L ${x} ${y}`);}return points.join(\" \");},[pathConfig]);const pathId=useMemo(()=>`wavy-path-${Math.random().toString(36).substr(2,9)}`,[]);const repeatedText=useMemo(()=>{const charWidth=responsiveFontSize*.6;const textLength=text.length*charWidth;const repetitions=Math.ceil(pathConfig.length/textLength)+2;const separator=\"\\xa0\".repeat(textSpacing);return Array(repetitions).fill(text).join(separator);},[text,pathConfig.length,textSpacing,responsiveFontSize]);const svgHeight=useMemo(()=>pathConfig.amplitude*2+pathConfig.width,[pathConfig.amplitude,pathConfig.width]);const containerHeight=useMemo(()=>isMobile?blockHeight*.7:blockHeight,[isMobile,blockHeight]);const textStyle=useMemo(()=>({fontSize:`${responsiveFontSize}px`,fill:textColor,fontWeight:\"bold\",...textFont}),[responsiveFontSize,textColor,textFont]);return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:{...props.style,position:\"relative\",width:\"100%\",height:containerHeight,backgroundColor,overflow:\"visible\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\"},children:/*#__PURE__*/_jsxs(\"svg\",{width:\"100%\",height:\"100%\",viewBox:`0 0 ${pathConfig.length} ${svgHeight}`,preserveAspectRatio:\"xMidYMid slice\",style:{position:\"absolute\",top:\"50%\",left:\"50%\",transform:\"translate(-50%, -50%)\",minWidth:\"100%\",minHeight:\"100%\"},children:[/*#__PURE__*/_jsx(\"defs\",{children:/*#__PURE__*/_jsx(\"path\",{id:pathId,d:svgPath,fill:\"none\"})}),/*#__PURE__*/_jsx(motion.path,{d:svgPath,fill:\"none\",stroke:pathColor,strokeWidth:pathConfig.width,strokeLinecap:\"round\"}),/*#__PURE__*/_jsx(motion.text,{style:textStyle,textAnchor:\"start\",dominantBaseline:\"middle\",children:/*#__PURE__*/_jsx(motion.textPath,{href:`#${pathId}`,startOffset:textOffset,children:repeatedText})})]})});}addPropertyControls(ScrollingTextPath,{text:{type:ControlType.String,title:\"Text\",defaultValue:\"Animated text along a path! 👀\"},blockHeight:{type:ControlType.Number,title:\"Block Height\",defaultValue:400,min:200,max:1e3,step:10,unit:\"px\"},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#5a7a6a\"},pathColor:{type:ControlType.Color,title:\"Path Color\",defaultValue:\"#f5c2d6\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"},pathWidth:{type:ControlType.Number,title:\"Path Width\",defaultValue:120,min:50,max:300,step:10,unit:\"px\"},scrollSpeed:{type:ControlType.Number,title:\"Scroll Speed\",defaultValue:1,min:.1,max:3,step:.1},pathCurve:{type:ControlType.Number,title:\"Path Curve\",defaultValue:1,min:.3,max:2,step:.1},textFont:{type:ControlType.Font,title:\"Text Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{variant:\"Bold\",fontSize:\"48px\",letterSpacing:\"-0.02em\",lineHeight:\"1em\"}},textSpacing:{type:ControlType.Number,title:\"Text Spacing\",defaultValue:20,min:1,max:50,step:1}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ScrollingTextPath\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"fixed\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ScrollingTextPath.map"],"mappings":"0RAMG,SAAwB,EAAkB,EAAM,CAAC,GAAK,CAAC,OAAK,iCAAiC,kBAAgB,UAAU,YAAU,UAAU,YAAU,UAAU,YAAU,IAAI,cAAY,EAAE,YAAU,EAAE,WAAS,cAAY,GAAG,cAAY,KAAK,EAAY,EAAaA,EAAO,KAAK,CAAM,CAAC,EAAe,GAAmBC,EAAS,IAAI,CAAO,EAAYC,MAAgB,CAAI,EAAa,SAAS,EAAkB,EAAa,QAAQ,YAAY,EAAI,EAAE,CAAC,CAAC,MAAc,CAAI,GAAO,IAAS,OAA+E,OAA5D,GAAa,CAAC,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