{"version":3,"file":"Tickerfield.Cod-wFSR.mjs","names":["React.useRef","React.useState"],"sources":["https:/framerusercontent.com/modules/vgp6zTtS87FDKhMCjMQp/D1dh1j8eshUlfqWsSsiN/Tickerfield.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";/**\n * @framerDisableUnlink\n *\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n */export default function RichTextTicker(props){const{richText,speed,gap,direction,hover,cornerRadius,showAlt,altSpacing,altFont,altColor,draggable}=props;const containerRef=React.useRef(null);const contentRef=React.useRef(null);const[contentSize,setContentSize]=React.useState(0);const dragStartPos=React.useRef({x:0,y:0});const currentTranslate=React.useRef(0);const isDragging=React.useRef(false);const lastDragPosition=React.useRef(0);React.useEffect(()=>{const updateSize=()=>{if(contentRef.current&&containerRef.current){const items=Array.from(contentRef.current.children);const halfLength=items.length/2;let totalSize=0;for(let i=0;i<halfLength;i++){if(direction===\"top\"||direction===\"bottom\"){totalSize+=items[i].offsetHeight+gap;}else{totalSize+=items[i].offsetWidth+gap;}}setContentSize(totalSize);}};updateSize();window.addEventListener(\"resize\",updateSize);return()=>window.removeEventListener(\"resize\",updateSize);},[richText,gap,direction]);React.useEffect(()=>{let animationFrameId=null;const animate=()=>{if(!isDragging.current&&contentRef.current&&speed>0){const scrollSize=direction===\"left\"||direction===\"right\"?contentRef.current.scrollWidth/2:contentRef.current.scrollHeight/2;if(direction===\"left\"||direction===\"up\"){currentTranslate.current-=speed/10;if(Math.abs(currentTranslate.current)>=scrollSize){currentTranslate.current+=scrollSize;}}else{currentTranslate.current+=speed/10;if(currentTranslate.current>=0){currentTranslate.current-=scrollSize;}}const transform=direction===\"left\"||direction===\"right\"?`translateX(${currentTranslate.current}px)`:`translateY(${currentTranslate.current}px)`;contentRef.current.style.transform=transform;}animationFrameId=requestAnimationFrame(animate);};if(!isDragging.current){animate();}return()=>{if(animationFrameId){cancelAnimationFrame(animationFrameId);}};},[speed,direction,isDragging.current]);const handleMouseDown=e=>{if(!draggable)return;e.preventDefault();isDragging.current=true;dragStartPos.current={x:e.clientX,y:e.clientY};const computedStyle=window.getComputedStyle(contentRef.current);const transform=new DOMMatrix(computedStyle.transform);currentTranslate.current=direction===\"left\"||direction===\"right\"?transform.m41:transform.m42;lastDragPosition.current=direction===\"left\"||direction===\"right\"?e.clientX:e.clientY;contentRef.current.style.cursor=\"grabbing\";document.addEventListener(\"mousemove\",handleMouseMove);document.addEventListener(\"mouseup\",handleMouseUp);};const handleMouseMove=e=>{if(!isDragging.current)return;e.preventDefault();const currentPos=direction===\"left\"||direction===\"right\"?e.clientX:e.clientY;const delta=currentPos-lastDragPosition.current;currentTranslate.current+=delta;const transform=direction===\"left\"||direction===\"right\"?`translateX(${currentTranslate.current}px)`:`translateY(${currentTranslate.current}px)`;contentRef.current.style.transform=transform;lastDragPosition.current=currentPos;};const handleMouseUp=()=>{isDragging.current=false;contentRef.current.style.cursor=\"grab\";document.removeEventListener(\"mousemove\",handleMouseMove);document.removeEventListener(\"mouseup\",handleMouseUp);};const handleTouchStart=e=>{if(!draggable)return;e.preventDefault();isDragging.current=true;const touch=e.touches[0];dragStartPos.current={x:touch.clientX,y:touch.clientY};const computedStyle=window.getComputedStyle(contentRef.current);const transform=new DOMMatrix(computedStyle.transform);currentTranslate.current=direction===\"left\"||direction===\"right\"?transform.m41:transform.m42;lastDragPosition.current=direction===\"left\"||direction===\"right\"?touch.clientX:touch.clientY;};const handleTouchMove=e=>{if(!isDragging.current)return;e.preventDefault();const touch=e.touches[0];const currentPos=direction===\"left\"||direction===\"right\"?touch.clientX:touch.clientY;const delta=currentPos-lastDragPosition.current;currentTranslate.current+=delta;const transform=direction===\"left\"||direction===\"right\"?`translateX(${currentTranslate.current}px)`:`translateY(${currentTranslate.current}px)`;contentRef.current.style.transform=transform;lastDragPosition.current=currentPos;};const handleTouchEnd=()=>{isDragging.current=false;};const containerStyle={overflow:\"hidden\",width:\"100%\",height:\"100%\",display:\"flex\",flexDirection:direction===\"top\"||direction===\"bottom\"?\"column\":\"row\"};const contentStyle={display:\"flex\",flexWrap:\"nowrap\",flexDirection:direction===\"top\"||direction===\"bottom\"?\"column\":\"row\",cursor:draggable?\"grab\":\"default\",userSelect:\"none\",WebkitUserSelect:\"none\",touchAction:\"none\",willChange:\"transform\"};const itemStyle={flexShrink:0,objectFit:\"contain\",marginRight:direction===\"left\"||direction===\"right\"?`${gap}px`:0,marginBottom:direction===\"top\"||direction===\"bottom\"?`${gap}px`:0,width:direction===\"top\"||direction===\"bottom\"?\"100%\":\"auto\",height:direction===\"top\"||direction===\"bottom\"?\"auto\":\"100%\"};const renderContent=()=>{if(!richText||!richText.props||!richText.props.children){return null;}const items=React.Children.toArray(richText.props.children);const allItems=[...items,...items];return allItems.map((child,index)=>/*#__PURE__*/_jsx(\"div\",{style:itemStyle,children:/*#__PURE__*/_jsxs(\"div\",{style:{position:\"relative\",height:\"100%\"},children:[/*#__PURE__*/React.cloneElement(child,{style:{...child.props.style,borderRadius:`${cornerRadius}px`,objectFit:\"cover\",width:\"100%\",height:showAlt?`calc(100% - ${altSpacing}px)`:\"100%\",pointerEvents:isDragging.current?\"none\":\"auto\"}}),showAlt&&child.props.alt&&/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",bottom:0,left:0,right:0,marginTop:altSpacing,textAlign:\"center\",color:altColor,...altFont},children:child.props.alt})]})},index));};if(RenderTarget.current()===RenderTarget.canvas){return /*#__PURE__*/_jsx(\"div\",{style:containerStyle,children:/*#__PURE__*/_jsx(\"div\",{style:{...contentStyle,transform:\"none\"},children:renderContent()})});}return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:containerStyle,children:/*#__PURE__*/_jsx(\"div\",{ref:contentRef,style:contentStyle,onMouseDown:handleMouseDown,onTouchStart:handleTouchStart,onTouchMove:handleTouchMove,onTouchEnd:handleTouchEnd,children:renderContent()})});}RichTextTicker.defaultProps={richText:null,speed:50,gap:20,direction:\"left\",hover:1,cornerRadius:0,showAlt:false,altSpacing:8,altColor:\"#000000\",draggable:false};addPropertyControls(RichTextTicker,{richText:{type:ControlType.RichText,title:\"Content\"},speed:{type:ControlType.Number,title:\"Speed\",min:0,max:100,step:1},gap:{type:ControlType.Number,title:\"Gap\",min:0,max:500,step:1},direction:{type:ControlType.Enum,title:\"Direction\",options:[\"left\",\"right\",\"top\",\"bottom\"],defaultValue:\"left\",displaySegmentedControl:true},hover:{type:ControlType.Number,title:\"Hover Speed\",min:0,max:1,step:.1,defaultValue:1},cornerRadius:{type:ControlType.Number,title:\"Corner Radius\",min:0,max:100,step:1,defaultValue:0},showAlt:{type:ControlType.Boolean,title:\"Show Alt Text\",defaultValue:false},altSpacing:{type:ControlType.Number,title:\"Alt Spacing\",min:0,max:100,step:1,defaultValue:8,hidden(props){return!props.showAlt;}},altColor:{type:ControlType.Color,title:\"Alt Color\",defaultValue:\"#000000\",hidden(props){return!props.showAlt;}},altFont:{type:ControlType.Font,controls:\"extended\",title:\"Alt Font\",hidden(props){return!props.showAlt;}},draggable:{type:ControlType.Boolean,title:\"Draggable\",defaultValue:false,description:\"v1.3 \\n[via SegmentUI](https://www.segmentUI.com)\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"RichTextTicker\",\"slots\":[],\"annotations\":{\"framerDisableUnlink\":\"*\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"any\",\"framerSupportedLayoutWidth\":\"any\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Tickerfield.map"],"mappings":"iWAKG,SAAwB,EAAe,EAAM,CAAC,GAAK,CAAC,WAAS,QAAM,MAAI,YAAU,QAAM,eAAa,UAAQ,aAAW,UAAQ,WAAS,aAAW,EAAY,EAAaA,EAAa,KAAK,CAAO,EAAWA,EAAa,KAAK,CAAM,CAAC,EAAY,GAAgBC,EAAe,EAAE,CAA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