{"version":3,"file":"HorizontalLoopText.vI7KUkCE.mjs","names":["useRef","useState","__esmMin","init_npm_react_18_3_1","te","_e","de","c","init_jsx_runtime","ce","init_framer_B6PCHH0A","RenderTarget","addPropertyControls","useIsStaticRenderer","ControlType","HorizontalLoopText","props","isStatic","containerRef","textRef","textWidth","setTextWidth","containerWidth","setContainerWidth","offset","setOffset","text","font","gap","style","frame","last","animate","dt","now","next","prev","speed","repeatCount","items","i","init_HorizontalLoopText"],"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__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./HorizontalLoopText.map"],"mappings":"A,+MASG,SAAwBe,EAAmB,EAAM,CAAC,GAAK,CAAC,OAAK,QAAM,MAAI,QAAM,OAAK,QAAM,iBAAeC,EAAYC,EAASJ,EAAoB,EAAQK,EAAalB,EAAO,IAAI,EAAQmB,EAAQnB,EAAO,IAAI,EAAO,CAACoB,EAAUC,GAAcpB,EAAS,CAAC,EAAO,CAACqB,EAAeC,GAAmBtB,EAAS,CAAC,EAAO,CAACuB,EAAOC,GAAWxB,EAAS,CAAC,EAGhV,GAFAQ,MAAc,CAAKS,EAAa,SAAUC,EAAQ,UAAeI,EAAkBL,EAAa,QAAQ,WAAW,EAAEG,EAAaF,EAAQ,QAAQ,WAAW,EAAE,EAAE,CAACO,EAAKC,EAAKC,EAAIC,GAAO,KAAK,CAAC,EAC7LpB,MAAc,CAAqE,GAAjEQ,GAAUN,EAAa,QAAQ,IAAIA,EAAa,WAAoBS,IAAY,EAAE,OAAO,IAAIU,EAAUC,EAAK,YAAY,IAAI,EAAE,SAASC,EAAQ,EAAI,CAAC,IAAMC,GAAIC,EAAIH,GAAM,IAAI,EAAKG,EAAI9B,MAAoB,CAACqB,EAAU,GAAM,CAAC,IAAIU,EAAKC,EAAKC,EAAMJ,EAAyD,OAAnD,KAAK,IAAIE,CAAI,EAAEf,EAAUQ,IAAK,GAAMR,EAAUQ,GAAYO,CAAK,CAAC,CAAE,CAAC,EAAE,EAAM,sBAAsBH,CAAO,CAAE,CAAsC,MAArC,GAAM,sBAAsBA,CAAO,MAAY,qBAAqBF,CAAK,C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