{"version":3,"file":"InfiniteScrollText.7tjzIQU5.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/49FZYMfjuVzRIBZiVA53/4CHlTHJV9meQutPp3UQh/InfiniteScrollText.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useRef,useEffect,useState}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer,RenderTarget}from\"framer\";export default function InfiniteScroll(props){const{texts,background,font,gradientColors,style,textColor,fillType,group={speed:80,direction:\"left\",rotate:0,spacing:32}}=props;const{speed,direction,rotate,spacing}=group;const isStatic=useIsStaticRenderer();const containerRef=useRef(null);const[textWidth,setTextWidth]=useState(0);const[viewWidth,setViewWidth]=useState(300);const[viewHeight,setViewHeight]=useState(100);const[offset,setOffset]=useState(0);// Measure container and first text block\nuseEffect(()=>{if(!containerRef.current)return;const w=containerRef.current.offsetWidth||300;const h=containerRef.current.offsetHeight||100;setViewWidth(w);setViewHeight(h);const blockEl=containerRef.current.querySelector(\".scroll-block\");if(blockEl)setTextWidth(blockEl.offsetWidth);},[texts,font,spacing,rotate]);// ✅ Calculate diagonal scaling factor for rotation\nconst radians=Math.abs(rotate)*Math.PI/180;const expandFactor=Math.abs(Math.cos(radians))+Math.abs(Math.sin(radians));const outerStyle={...style,width:\"100%\",height:\"100%\",minWidth:300,minHeight:100,overflow:\"visible\",position:\"relative\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\"};const rotatingContainerStyle={position:\"absolute\",top:\"50%\",left:\"50%\",width:`${100*expandFactor}%`,height:`${100*expandFactor}%`,background,transform:`translate(-50%, -50%) rotate(${rotate}deg)`,transformOrigin:\"center center\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",overflow:\"hidden\"};const scrollStyle={display:\"flex\",flexDirection:\"row\",whiteSpace:\"nowrap\",willChange:\"transform\",transform:`translateX(${offset}px)`};const numDuplicates=textWidth>0?Math.ceil(viewWidth/textWidth)+2:3;// Scroll animation\nuseEffect(()=>{if(isStatic||RenderTarget.current()===RenderTarget.thumbnail||textWidth<=0)return;let frame;let last=performance.now();function animate(now){const elapsed=now-last;last=now;const delta=speed/1e3*elapsed*(direction===\"left\"?-1:1);setOffset(prev=>{let next=prev+delta;const blockWidth=textWidth;while(next>0)next-=blockWidth;while(next<-blockWidth)next+=blockWidth;return next;});frame=requestAnimationFrame(animate);}frame=requestAnimationFrame(animate);return()=>cancelAnimationFrame(frame);},[speed,direction,textWidth,isStatic]);const repeatedText=Array.from({length:numDuplicates}).map((_,i)=>/*#__PURE__*/_jsx(\"ul\",{className:i===0?\"scroll-block\":undefined,style:{display:\"flex\",margin:0,padding:0,listStyle:\"none\"},children:texts.map((t,idx)=>/*#__PURE__*/_jsx(\"li\",{style:{...getTextStyle({font,gradientColors,textColor,fillType}),whiteSpace:\"nowrap\",display:\"inline-block\",marginRight:spacing},children:t},idx))},i));if(isStatic||RenderTarget.current()===RenderTarget.thumbnail){return /*#__PURE__*/_jsx(\"div\",{style:outerStyle,children:/*#__PURE__*/_jsx(\"div\",{style:rotatingContainerStyle,children:texts.length>0?texts.map((t,idx)=>/*#__PURE__*/_jsx(\"span\",{style:{...getTextStyle({font,gradientColors,textColor,fillType}),whiteSpace:\"nowrap\",marginLeft:idx===0?0:spacing},children:t},idx)):/*#__PURE__*/_jsx(\"span\",{style:{...font,opacity:.5,fontSize:14},children:\"Add text items.\"})})});}return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:outerStyle,children:/*#__PURE__*/_jsx(\"div\",{style:rotatingContainerStyle,children:/*#__PURE__*/_jsx(\"div\",{style:scrollStyle,children:repeatedText})})});}// Helper function for text styling\nfunction getTextStyle({font,gradientColors,textColor,fillType}){if(fillType===\"color\")return{...font,color:textColor};if(!gradientColors||gradientColors.length===0)return{...font,color:textColor};if(gradientColors.length===1)return{...font,color:gradientColors[0]};const gradient=`linear-gradient(90deg, ${gradientColors.join(\", \")})`;return{...font,backgroundImage:gradient,backgroundRepeat:\"no-repeat\",backgroundSize:\"100% 100%\",backgroundClip:\"text\",WebkitBackgroundClip:\"text\",color:\"transparent\",WebkitTextFillColor:\"transparent\"};}// Framer property controls\naddPropertyControls(InfiniteScroll,{group:{type:ControlType.Object,title:\"Scroll Settings\",controls:{speed:{type:ControlType.Number,title:\"Speed\",defaultValue:80,min:10,max:500,unit:\"px/s\",step:1},direction:{type:ControlType.Enum,title:\"Direction\",options:[\"left\",\"right\"],optionTitles:[\"Left\",\"Right\"],defaultValue:\"left\",displaySegmentedControl:true},rotate:{type:ControlType.Number,title:\"Rotate\",defaultValue:0,min:-180,max:180,unit:\"deg\"},spacing:{type:ControlType.Number,title:\"Spacing\",defaultValue:32,min:0,max:200,unit:\"px\"}}},texts:{type:ControlType.Array,title:\"Texts\",control:{type:ControlType.String,defaultValue:\"Infinite Scroll Text\"},defaultValue:[],maxCount:10},background:{type:ControlType.Color,title:\"Background\",defaultValue:\"#FFFFFF\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\",hidden:p=>p.fillType===\"gradient\"},gradientColors:{type:ControlType.Array,title:\"Text Colors\",control:{type:ControlType.Color,defaultValue:\"#7928CA\"},defaultValue:[],maxCount:5,hidden:p=>p.fillType===\"color\"},fillType:{type:ControlType.Enum,title:\"Fill\",options:[\"color\",\"gradient\"],optionTitles:[\"Color\",\"Gradient\"],defaultValue:\"color\",displaySegmentedControl:true}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"InfiniteScroll\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./InfiniteScrollText.map"],"mappings":"kMAA6K,SAAwB,EAAe,EAAM,CAAC,GAAK,CAAC,QAAM,aAAW,OAAK,iBAAe,QAAM,YAAU,WAAS,QAAM,CAAC,MAAM,GAAG,UAAU,OAAO,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAW,CA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