{"version":3,"file":"twice_textticker.BZushMeQ.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/hwQGVb7f2efO55ZXAodP/NIu9EXI5Dw6xw3s8VBDl/twice_textticker.js"],"sourcesContent":["// Text Ticker component with scroll-based direction control, customizable font, size, color and stroke\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useState,useRef,startTransition}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";import{motion,useInView,useMotionValue,useAnimationFrame}from\"framer-motion\";/**\n * Text Ticker - Endless scrolling text ticker with customizable font, color and stroke\n *\n * @framerIntrinsicWidth 800\n * @framerIntrinsicHeight 60\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function TextTicker(props){const{textSource=\"custom\",texts=[\"Sample Text\",\"Another Text\",\"More Text\"],cmsText=\"CMS Text\",directionMode=\"scroll\",direction=\"left\",speed=50,gap=40,font,textColor=\"#000000\",enableStroke=false,strokeWidth=2,strokeColor=\"#FFFFFF\",backgroundColor=\"transparent\",enableSvg=false,svgCode='<svg viewBox=\"0 0 24 24\" fill=\"currentColor\"><circle cx=\"12\" cy=\"12\" r=\"8\"/></svg>',svgColor=\"#000000\",svgSize=1,svgStrokeWidth=1,uppercase=false,style}=props;const containerRef=useRef(null);const contentRef=useRef(null);const[scrollDirection,setScrollDirection]=useState(\"down\");const[lastScrollY,setLastScrollY]=useState(0);const[contentWidth,setContentWidth]=useState(0);const isStatic=useIsStaticRenderer();const isInView=useInView(containerRef,{margin:\"-50px\"});// Motion values for smooth animation\nconst x=useMotionValue(0);const[currentDirection,setCurrentDirection]=useState(direction);// Track scroll direction\nuseEffect(()=>{if(isStatic||typeof window===\"undefined\")return;const handleScroll=()=>{const currentScrollY=window.scrollY;if(currentScrollY>lastScrollY){startTransition(()=>setScrollDirection(\"down\"));}else if(currentScrollY<lastScrollY){startTransition(()=>setScrollDirection(\"up\"));}setLastScrollY(currentScrollY);};window.addEventListener(\"scroll\",handleScroll,{passive:true});return()=>window.removeEventListener(\"scroll\",handleScroll);},[lastScrollY,isStatic]);// Determine final direction based on scroll and prop\nconst finalDirection=directionMode===\"fixed\"?direction:scrollDirection===\"down\"?direction:direction===\"left\"?\"right\":\"left\";// Measure actual content width\nuseEffect(()=>{if(!contentRef.current)return;const measureContent=()=>{const content=contentRef.current;if(!content)return;// Measure the actual scrollWidth of one set of texts\nconst singleSetWidth=content.scrollWidth/3// Since we have 3 sets\n;setContentWidth(singleSetWidth);};measureContent();const resizeObserver=new ResizeObserver(measureContent);if(contentRef.current){resizeObserver.observe(contentRef.current);}return()=>resizeObserver.disconnect();},[texts,gap,font]);// Determine which texts to use based on source\nconst activeTexts=textSource===\"cms\"?[cmsText]:texts;// Create duplicated texts for seamless loop\nconst duplicatedTexts=[...activeTexts,...activeTexts,...activeTexts];// Update direction smoothly\nuseEffect(()=>{setCurrentDirection(finalDirection);},[finalDirection]);// Animation frame loop for continuous movement\nuseAnimationFrame((time,delta)=>{if(isStatic||contentWidth===0)return;const pixelsPerMs=speed/1e3;const movement=delta*pixelsPerMs;if(currentDirection===\"left\"){x.set(x.get()-movement);// Reset position when we've moved one section\nif(x.get()<=-contentWidth){x.set(x.get()+contentWidth);}}else{x.set(x.get()+movement);// Reset position when we've moved one section\nif(x.get()>=0){x.set(x.get()-contentWidth);}}});// Initialize position based on direction\nuseEffect(()=>{if(currentDirection===\"right\"&&x.get()===0&&contentWidth>0){x.set(-contentWidth);}},[currentDirection,contentWidth]);// Create text elements with proper styling\nconst createTextElement=(text,index)=>/*#__PURE__*/_jsxs(\"span\",{style:{marginRight:`${gap}px`,whiteSpace:\"nowrap\",color:enableStroke?\"transparent\":textColor,WebkitTextStroke:enableStroke?`${strokeWidth}px ${strokeColor}`:\"none\",paintOrder:enableStroke?\"stroke fill\":\"normal\",flexShrink:0,display:\"flex\",alignItems:\"center\",gap:enableSvg?`${gap/2}px`:\"0px\",textTransform:uppercase?\"uppercase\":\"none\",...font},children:[text,enableSvg&&/*#__PURE__*/_jsx(\"span\",{style:{display:\"inline-flex\",alignItems:\"center\",height:\"1em\",color:svgColor,width:`${svgSize}em`,justifyContent:\"center\",flexShrink:0,transform:`translate(${props.svgPositionX||0}px, ${props.svgPositionY||0}px)`},dangerouslySetInnerHTML:{__html:svgCode.replace(/fill=\"[^\"]*\"/g,'fill=\"none\"').replace(/stroke=\"[^\"]*\"/g,`stroke=\"currentColor\"`).replace(/stroke-width=\"[^\"]*\"/g,`stroke-width=\"${svgStrokeWidth}\"`).replace(/width=\"[^\"]*\"/g,\"\").replace(/height=\"[^\"]*\"/g,\"\").replace(/<svg/,`<svg width=\"${svgSize}em\" height=\"${svgSize}em\" stroke=\"currentColor\" stroke-width=\"${svgStrokeWidth}\" fill=\"none\"`)}})]},index);if(isStatic){return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:{...style,width:\"100%\",height:\"100%\",backgroundColor,overflow:\"hidden\",display:\"flex\",alignItems:\"center\",position:\"relative\"},children:/*#__PURE__*/_jsx(\"div\",{style:{display:\"flex\",alignItems:\"center\",whiteSpace:\"nowrap\",paddingLeft:0,paddingRight:0},children:activeTexts.slice(0,Math.min(5,activeTexts.length)).map((text,index)=>createTextElement(text,index))})});}return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:{...style,width:\"100%\",height:\"100%\",backgroundColor,overflow:\"hidden\",display:\"flex\",alignItems:\"center\",position:\"relative\",WebkitBackfaceVisibility:\"hidden\",backfaceVisibility:\"hidden\",WebkitPerspective:1e3,perspective:1e3},children:/*#__PURE__*/_jsx(motion.div,{ref:contentRef,style:{display:\"flex\",alignItems:\"center\",whiteSpace:\"nowrap\",paddingLeft:0,paddingRight:0,x,willChange:\"transform\",WebkitBackfaceVisibility:\"hidden\",backfaceVisibility:\"hidden\"},children:duplicatedTexts.map((text,index)=>createTextElement(text,index))})});}addPropertyControls(TextTicker,{textSource:{type:ControlType.Enum,title:\"Text Source\",options:[\"custom\",\"cms\"],optionTitles:[\"Custom\",\"CMS\"],defaultValue:\"custom\",displaySegmentedControl:true},texts:{type:ControlType.Array,title:\"Texts\",control:{type:ControlType.String,placeholder:\"Enter text...\"},defaultValue:[\"Sample Text\",\"Another Text\",\"More Text\"],maxCount:20,hidden:({textSource})=>textSource===\"cms\"},cmsText:{type:ControlType.String,title:\"CMS Text\",defaultValue:\"CMS Text\",hidden:({textSource})=>textSource===\"custom\"},directionMode:{type:ControlType.Enum,title:\"Direction Mode\",options:[\"scroll\",\"fixed\"],optionTitles:[\"Scroll-Based\",\"Fixed\"],defaultValue:\"scroll\",displaySegmentedControl:true},direction:{type:ControlType.Enum,title:\"Direction\",options:[\"left\",\"right\"],optionTitles:[\"Left\",\"Right\"],defaultValue:\"left\",displaySegmentedControl:true},speed:{type:ControlType.Number,title:\"Speed\",defaultValue:50,min:10,max:200,step:5,unit:\"px/s\"},gap:{type:ControlType.Number,title:\"Gap\",defaultValue:40,min:-100,max:200,step:5,unit:\"px\"},font:{type:ControlType.Font,title:\"Font\",defaultValue:{fontSize:\"2em\",variant:\"Bold\",letterSpacing:\"-0.02em\",lineHeight:\"1em\"},controls:\"extended\",defaultFontType:\"sans-serif\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"},enableStroke:{type:ControlType.Boolean,title:\"Enable Stroke\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"},strokeWidth:{type:ControlType.Number,title:\"Stroke Width\",defaultValue:2,min:.1,max:10,step:.1,unit:\"px\",hidden:({enableStroke})=>!enableStroke},strokeColor:{type:ControlType.Color,title:\"Stroke Color\",defaultValue:\"#FFFFFF\",hidden:({enableStroke})=>!enableStroke},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"rgba(0,0,0,0)\"},enableSvg:{type:ControlType.Boolean,title:\"Enable SVG\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"},svgCode:{type:ControlType.String,title:\"SVG Code\",defaultValue:'<svg viewBox=\"0 0 24 24\" fill=\"currentColor\"><circle cx=\"12\" cy=\"12\" r=\"8\"/></svg>',hidden:({enableSvg})=>!enableSvg},svgColor:{type:ControlType.Color,title:\"SVG Color\",defaultValue:\"#000000\",hidden:({enableSvg})=>!enableSvg},svgSize:{type:ControlType.Number,title:\"SVG Size\",defaultValue:1,min:.1,max:5,step:.1,unit:\"em\",hidden:({enableSvg})=>!enableSvg},svgStrokeWidth:{type:ControlType.Number,title:\"SVG Stroke Width\",defaultValue:1,min:.1,max:10,step:.1,unit:\"px\",hidden:({enableSvg})=>!enableSvg},svgPositionX:{type:ControlType.Number,title:\"SVG Position X\",defaultValue:0,min:-50,max:50,step:1,unit:\"px\",hidden:({enableSvg})=>!enableSvg},svgPositionY:{type:ControlType.Number,title:\"SVG Position Y\",defaultValue:0,min:-50,max:50,step:1,unit:\"px\",hidden:({enableSvg})=>!enableSvg},uppercase:{type:ControlType.Boolean,title:\"Uppercase\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TextTicker\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerIntrinsicHeight\":\"60\",\"framerIntrinsicWidth\":\"800\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./twice_textticker.map"],"mappings":"2eASG,SAAwB,EAAW,EAAM,CAAC,GAAK,CAAC,aAAW,SAAS,QAAM,CAAC,cAAc,eAAe,YAAY,CAAC,UAAQ,WAAW,gBAAc,SAAS,YAAU,OAAO,QAAM,GAAG,MAAI,GAAG,OAAK,YAAU,UAAU,eAAa,GAAM,cAAY,EAAE,cAAY,UAAU,kBAAgB,cAAc,YAAU,GAAM,UAAQ,qFAAqF,WAAS,UAAU,UAAQ,EAAE,iBAAe,EAAE,YAAU,GAAM,S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