{"version":3,"file":"HorizontalLoopText.3DfWHulF.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/Euj1F37uyVmpuKsceP50/1pDFXQy8qUzODOOQhbt8/HorizontalLoopText.js"],"sourcesContent":["// Tekst przewijany w poziomie, zapętlony, z kontrolami Framer\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useRef,useEffect,useState,startTransition}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer,RenderTarget}from\"framer\";/**\n * Poziomy przewijany tekst (marquee)\n *\n * @framerIntrinsicWidth 400\n * @framerIntrinsicHeight 48\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight fixed\n */export default function HorizontalLoopText(props){const{text,speed,gap,color,font,style,textTransform}=props;const isStatic=useIsStaticRenderer();const containerRef=useRef(null);const textRef=useRef(null);const[textWidth,setTextWidth]=useState(0);const[containerWidth,setContainerWidth]=useState(0);const[offset,setOffset]=useState(0);// Pomiar szerokości tekstu i kontenera\nuseEffect(()=>{if(!containerRef.current||!textRef.current)return;setContainerWidth(containerRef.current.offsetWidth);setTextWidth(textRef.current.offsetWidth);},[text,font,gap,style?.width]);// Animacja przesuwania\nuseEffect(()=>{if(isStatic||RenderTarget.current()===RenderTarget.thumbnail)return;if(textWidth===0)return;let frame;let last=performance.now();function animate(now){const dt=(now-last)/1e3;last=now;startTransition(()=>{setOffset(prev=>{let next=prev-speed*dt;if(Math.abs(next)>textWidth+gap){next+=textWidth+gap;}return next;});});frame=requestAnimationFrame(animate);}frame=requestAnimationFrame(animate);return()=>cancelAnimationFrame(frame);},[speed,textWidth,gap,isStatic]);// Static preview\nif(isStatic||RenderTarget.current()===RenderTarget.thumbnail){return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:{...style,width:\"100%\",height:\"100%\",overflow:\"hidden\",display:\"flex\",alignItems:\"center\",position:\"relative\",borderRadius:8},children:/*#__PURE__*/_jsx(\"div\",{ref:textRef,style:{color,whiteSpace:\"nowrap\",...font,marginRight:gap,textTransform},children:text})});}// Liczba powtórzeń tekstu (minimum 2)\nconst repeatCount=textWidth>0&&containerWidth>0?Math.ceil(containerWidth/(textWidth+gap))+2:2;const items=Array.from({length:repeatCount},(_,i)=>/*#__PURE__*/_jsx(\"div\",{ref:i===0?textRef:undefined,style:{color,whiteSpace:\"nowrap\",...font,marginRight:gap,display:\"inline-block\",textTransform},children:text},i));return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:{...style,width:\"100%\",height:\"100%\",overflow:\"hidden\",display:\"flex\",alignItems:\"center\",position:\"relative\",borderRadius:8},children:/*#__PURE__*/_jsx(\"div\",{style:{display:\"flex\",flexDirection:\"row\",willChange:\"transform\",transform:`translateX(${offset}px)`},children:items})});}addPropertyControls(HorizontalLoopText,{text:{type:ControlType.String,title:\"Tekst\",defaultValue:\"To jest przewijany tekst!\"},speed:{type:ControlType.Number,title:\"Szybkość\",defaultValue:60,min:10,max:400,unit:\"px/s\",step:1},gap:{type:ControlType.Number,title:\"Odstęp\",defaultValue:48,min:0,max:200,step:1,unit:\"px\"},color:{type:ControlType.Color,title:\"Kolor tekstu\",defaultValue:\"#000000\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"32px\",variant:\"Bold\",letterSpacing:\"-0.01em\",lineHeight:\"1em\"}},textTransform:{type:ControlType.Enum,title:\"Transformacja tekstu\",options:[\"none\",\"uppercase\",\"lowercase\",\"capitalize\"],optionTitles:[\"Brak\",\"Wielkie litery\",\"Małe litery\",\"Kapitalizacja\"],defaultValue:\"none\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"HorizontalLoopText\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"fixed\",\"framerContractVersion\":\"1\",\"framerIntrinsicWidth\":\"400\",\"framerIntrinsicHeight\":\"48\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\"}},\"__FramerMetadata__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