{"version":3,"file":"TextTicker.DBObGJOF.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/vJsrs08ioWdlFeCsCORF/iSBd4WRVpCLuAOKyQT9q/TextTicker.js"],"sourcesContent":["// Simple horizontal text ticker that scrolls text continuously\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useRef,useEffect,useState,startTransition}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";/**\n * Simple Text Ticker\n *\n * @framerIntrinsicWidth 300\n * @framerIntrinsicHeight 50\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight fixed\n */export default function TextTicker(props){const{text=\"Breaking News\",speed=40,gap=40,textColor=\"#000000\",font,style,reverseOnScroll=true}=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);const[direction,setDirection]=useState(1);const[repeatCount,setRepeatCount]=useState(10);useEffect(()=>{if(typeof window===\"undefined\"||!containerRef.current||!textRef.current)return;const tw=textRef.current.offsetWidth;const cw=containerRef.current.offsetWidth;setTextWidth(tw);setContainerWidth(cw);if(tw>0&&cw>0){const minRepeats=Math.ceil(cw*3/(tw+gap));setRepeatCount(Math.max(minRepeats,10));}},[text,font,gap]);useEffect(()=>{if(!reverseOnScroll||isStatic)return;let lastScrollX=window.scrollX;const handleScroll=()=>{const currentScrollX=window.scrollX;if(currentScrollX>lastScrollX){// Scrolling right\nstartTransition(()=>setDirection(1));}else if(currentScrollX<lastScrollX){// Scrolling left\nstartTransition(()=>setDirection(-1));}lastScrollX=currentScrollX;};window.addEventListener(\"scroll\",handleScroll,{passive:true});return()=>window.removeEventListener(\"scroll\",handleScroll);},[reverseOnScroll,isStatic]);useEffect(()=>{if(isStatic)return;if(textWidth===0)return;let frame;let last=performance.now();function tick(now){const dt=(now-last)/1e3;last=now;startTransition(()=>{setOffset(prev=>{let next=prev-speed*direction*dt;const stripWidth=textWidth+gap;if(next<=-stripWidth){next+=stripWidth;}else if(next>0){next-=stripWidth;}return next;});});frame=requestAnimationFrame(tick);}frame=requestAnimationFrame(tick);return()=>cancelAnimationFrame(frame);},[speed,textWidth,gap,repeatCount,isStatic,direction]);useEffect(()=>{setOffset(0);},[text,textWidth,gap]);return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:{position:\"relative\",width:\"100%\",height:\"100%\",overflow:\"hidden\",...style},children:/*#__PURE__*/_jsx(\"div\",{style:{display:\"flex\",flexDirection:\"row\",alignItems:\"center\",position:\"absolute\",left:0,top:0,height:\"100%\",willChange:\"transform\",transform:isStatic?undefined:`translateX(${offset}px)`},children:Array.from({length:repeatCount}).map((_,i)=>/*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\"},children:[/*#__PURE__*/_jsx(\"div\",{ref:i===0?textRef:undefined,style:{color:textColor,whiteSpace:\"nowrap\",...font},children:text}),/*#__PURE__*/_jsx(\"div\",{style:{width:gap}})]},i))})});}addPropertyControls(TextTicker,{reverseOnScroll:{type:ControlType.Boolean,title:\"Direction with Scroll\",defaultValue:true,enabledTitle:\"Yes\",disabledTitle:\"No\"},text:{type:ControlType.String,title:\"Text\",defaultValue:\"Breaking News\"},speed:{type:ControlType.Number,title:\"Speed\",defaultValue:40,min:10,max:200,step:1},gap:{type:ControlType.Number,title:\"Gap\",defaultValue:40,min:0,max:200,step:1},textColor:{type:ControlType.Color,title:\"Color\",defaultValue:\"#000000\"},font:{type:ControlType.Font,title:\"Font\",defaultValue:{fontSize:18,lineHeight:1.3,letterSpacing:0,textAlign:\"left\",variant:\"Medium\"},controls:\"extended\",defaultFontType:\"sans-serif\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TextTicker\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerIntrinsicHeight\":\"50\",\"framerIntrinsicWidth\":\"300\",\"framerSupportedLayoutWidth\":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