{"version":3,"file":"Custom_ticker.CrdHHRKD.mjs","names":["useRef","useState","React","contentWidth"],"sources":["https:/framerusercontent.com/modules/8HmAXsxZy34cvSzysRv3/5gIXMAGT7HOykr0SUzmQ/Custom_ticker.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import React,{useEffect,useRef,useState}from\"react\";import{motion}from\"framer-motion\";import{addPropertyControls,ControlType}from\"framer\";export function Ticker(props){const{children,speed,direction,gap,padding,verticalAlignment}=props;const containerRef=useRef(null);const[contentWidth,setContentWidth]=useState(0);const[animationKeyframes,setAnimationKeyframes]=useState({});const[isInView,setIsInView]=useState(true);const[scrollPosition,setScrollPosition]=useState(0);const[isTouching,setIsTouching]=useState(false);const[startTouch,setStartTouch]=useState(0);const[startMouse,setStartMouse]=useState(0);const[isMouseDown,setIsMouseDown]=useState(false);const isHorizontal=direction===\"left\"||direction===\"right\";// Check if children are available\nconst hasChildren=React.Children.count(children)>0;// Recalculate content size\nuseEffect(()=>{const updateContentWidth=()=>{if(containerRef.current){const contentWidth=containerRef.current.scrollWidth;setContentWidth(contentWidth);}};updateContentWidth();window.addEventListener(\"resize\",updateContentWidth);return()=>window.removeEventListener(\"resize\",updateContentWidth);},[children]);// Set animation keyframes based on direction\nuseEffect(()=>{const animationDirection={left:{x:[\"0%\",\"-100%\"]},right:{x:[\"-100%\",\"0%\"]},up:{y:[\"0%\",\"-100%\"]},down:{y:[\"-100%\",\"0%\"]}};setAnimationKeyframes(animationDirection[direction]||animationDirection.left);},[direction]);// Calculate animation speed in pixels per second\nconst effectiveSpeed=Math.max(speed,1)// minimum 1 pixel per second\n;// Generate repeated children\nconst repeatChildren=React.Children.toArray(children);// Function to generate repeated children to fill container\nconst generateRepeatedChildren=()=>{const childrenWidth=repeatChildren.reduce((acc,child)=>{const childWidth=child.props?child.props.style?.width||0:0;return acc+childWidth+gap;},0);// Determine the number of repetitions\nconst count=Math.ceil(contentWidth/(childrenWidth+gap));return Array(count).fill(repeatChildren).flat();};// Generate children\nconst repeatedChildren=generateRepeatedChildren();// Handle scroll\nconst handleScroll=event=>{if(containerRef.current){setScrollPosition(containerRef.current.scrollLeft);}};// Handle touch swipe events\nconst handleTouchStart=event=>{setIsTouching(true);setStartTouch(event.touches[0].clientX);};const handleTouchMove=event=>{if(isTouching){const touchMove=event.touches[0].clientX;const delta=startTouch-touchMove;// Scroll content based on swipe\nif(containerRef.current){containerRef.current.scrollLeft+=delta;}setStartTouch(touchMove);}};const handleTouchEnd=()=>{setIsTouching(false);};// Handle mouse drag events\nconst handleMouseDown=event=>{setIsMouseDown(true);setStartMouse(event.clientX);};const handleMouseMove=event=>{if(isMouseDown){const mouseMove=event.clientX;const delta=startMouse-mouseMove;// Scroll content based on mouse movement\nif(containerRef.current){containerRef.current.scrollLeft+=delta;}setStartMouse(mouseMove);}};const handleMouseUp=()=>{setIsMouseDown(false);};// Define vertical alignment styles\nconst getVerticalAlignmentStyles=()=>{switch(verticalAlignment){case\"top\":return{alignItems:\"flex-start\"};case\"center\":return{alignItems:\"center\"};case\"bottom\":return{alignItems:\"flex-end\"};default:return{alignItems:\"center\"};}};return /*#__PURE__*/_jsxs(\"div\",{ref:containerRef,style:{display:\"flex\",flexDirection:isHorizontal?\"row\":\"column\",padding:`${padding.top}px ${padding.right}px ${padding.bottom}px ${padding.left}px`,position:\"relative\",overflow:\"hidden\",width:\"100%\",height:\"100%\"},onScroll:handleScroll,onTouchStart:handleTouchStart,onTouchMove:handleTouchMove,onTouchEnd:handleTouchEnd,onMouseDown:handleMouseDown,onMouseMove:handleMouseMove,onMouseUp:handleMouseUp,children:[!hasChildren&&/*#__PURE__*/_jsx(\"div\",{style:{width:\"400px\",height:\"200px\",display:\"flex\",justifyContent:\"center\",alignItems:\"center\",backgroundColor:\"#E7EAFD\",color:\"#4453B4\",fontSize:\"12px\",textAlign:\"center\"},children:\"CONNECT TO CONTENT\"}),hasChildren&&/*#__PURE__*/_jsx(motion.div,{style:{display:\"flex\",gap:`${gap}px`,flexDirection:isHorizontal?\"row\":\"column\",minWidth:\"100%\",width:\"auto\",...getVerticalAlignmentStyles()},animate:isInView?animationKeyframes:{},transition:{duration:contentWidth/effectiveSpeed,repeat:Infinity,ease:\"linear\"},children:repeatedChildren.map((child,index)=>/*#__PURE__*/_jsx(\"div\",{style:{display:\"inline-flex\",justifyContent:\"center\",alignItems:\"center\",flexShrink:0},children:child},index))})]});}// Add property controls through addPropertyControls for Framer\naddPropertyControls(Ticker,{children:{type:ControlType.Array,propertyControl:{type:ControlType.ComponentInstance}},speed:{type:ControlType.Number,min:1,max:100,step:1,defaultValue:50},direction:{type:ControlType.Enum,options:[\"left\",\"right\",\"up\",\"down\"],optionTitles:[\"←\",\"→\",\"↑\",\"↓\"],defaultValue:\"left\"},gap:{type:ControlType.Number,min:0,max:100,step:1,defaultValue:10},padding:{type:ControlType.FusedNumber,toggleKey:\"custom\",valueKeys:[\"top\",\"right\",\"bottom\",\"left\"],defaultValue:{top:0,right:0,bottom:0,left:0}},verticalAlignment:{type:ControlType.Enum,options:[\"top\",\"center\",\"bottom\"],optionTitles:[\"Top\",\"Center\",\"Bottom\"],defaultValue:\"center\"}});Ticker.defaultProps={children:[],speed:50,direction:\"left\",gap:10,padding:{top:0,right:0,bottom:0,left:0},verticalAlignment:\"center\"};\nexport const __FramerMetadata__ = {\"exports\":{\"Ticker\":{\"type\":\"reactComponent\",\"name\":\"Ticker\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Custom_ticker.map"],"mappings":"qQAAmM,SAAgB,EAAO,EAAM,CAAC,GAAK,CAAC,WAAS,QAAM,YAAU,MAAI,UAAQ,qBAAmB,EAAY,EAAaA,EAAO,KAAK,CAAM,CAAC,EAAa,GAAiBC,EAAS,EAAE,CAAM,CAAC,EAAmB,GAAuBA,EAAS,EAAE,CAAC,CAAM,CAAC,EAAS,GAAaA,EAAS,GAAK,CAAM,CAAC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