{"version":3,"file":"Custom_ticker.Bq84s-e0.mjs","names":["useRef","useState","React"],"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,IAAI,EAAO,CAAC,EAAa,GAAiBC,EAAS,CAAC,EAAO,CAAC,EAAmB,GAAuBA,EAAS,CAAC,CAAC,EAAO,CAAC,EAAS,GAAaA,EAAS,EAAI,EAAO,CAAC,EAAe,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