{"version":3,"file":"Ticker.ChaGEMHi.mjs","names":["useRef","useState","_Fragment"],"sources":["https:/framerusercontent.com/modules/zLvAo4ibWvjPNJrPDheL/XE7ppxNmQ9okcIOntnGo/Ticker.js"],"sourcesContent":["// Ticker component that scrolls through child elements automatically and stops at the end\nimport{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{motion,useAnimationControls}from\"framer-motion\";import{useEffect,useRef,useState,startTransition}from\"react\";/**\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function Ticker(props){const{children,speed=50,gap=20,direction=\"left\",pauseOnHover=true,clipping=\"hidden\",fadeWidth=50}=props;const containerRef=useRef(null);const contentRef=useRef(null);const controls=useAnimationControls();const[contentWidth,setContentWidth]=useState(0);const[containerWidth,setContainerWidth]=useState(0);const[isHovered,setIsHovered]=useState(false);const[isDragging,setIsDragging]=useState(false);const[dragStart,setDragStart]=useState(0);const[currentX,setCurrentX]=useState(0);useEffect(()=>{if(!contentRef.current||!containerRef.current)return;const updateDimensions=()=>{if(contentRef.current&&containerRef.current){const content=contentRef.current.scrollWidth;const container=containerRef.current.offsetWidth;startTransition(()=>{setContentWidth(content);setContainerWidth(container);});}};updateDimensions();const resizeObserver=new ResizeObserver(updateDimensions);resizeObserver.observe(contentRef.current);resizeObserver.observe(containerRef.current);return()=>resizeObserver.disconnect();},[children]);useEffect(()=>{if(contentWidth===0||containerWidth===0)return;if(contentWidth<=containerWidth)return;if(isDragging)return;const distance=contentWidth-containerWidth;const duration=distance/speed;const animate=async()=>{if(isHovered&&pauseOnHover)return;await controls.start({x:direction===\"left\"?-distance:distance,transition:{duration,ease:\"linear\"}});};animate();},[contentWidth,containerWidth,speed,direction,controls,isHovered,pauseOnHover,isDragging]);const handleMouseEnter=()=>{if(pauseOnHover){startTransition(()=>setIsHovered(true));controls.stop();}};const handleMouseLeave=()=>{if(pauseOnHover){startTransition(()=>setIsHovered(false));}};const handleDragStart=e=>{startTransition(()=>setIsDragging(true));controls.stop();const clientX=\"touches\"in e?e.touches[0].clientX:e.clientX;setDragStart(clientX-currentX);};const handleDragMove=e=>{if(!isDragging)return;const clientX=\"touches\"in e?e.touches[0].clientX:e.clientX;const newX=clientX-dragStart;// Constrain dragging within bounds\nconst maxDistance=containerWidth-contentWidth;const constrainedX=Math.min(0,Math.max(maxDistance,newX));startTransition(()=>setCurrentX(constrainedX));controls.set({x:constrainedX});};const handleDragEnd=()=>{startTransition(()=>setIsDragging(false));};useEffect(()=>{if(!isDragging)return;const handleGlobalMove=e=>{const clientX=\"touches\"in e?e.touches[0].clientX:e.clientX;const newX=clientX-dragStart;const maxDistance=containerWidth-contentWidth;const constrainedX=Math.min(0,Math.max(maxDistance,newX));startTransition(()=>setCurrentX(constrainedX));controls.set({x:constrainedX});};const handleGlobalEnd=()=>{startTransition(()=>setIsDragging(false));};window.addEventListener(\"mousemove\",handleGlobalMove);window.addEventListener(\"mouseup\",handleGlobalEnd);window.addEventListener(\"touchmove\",handleGlobalMove);window.addEventListener(\"touchend\",handleGlobalEnd);return()=>{window.removeEventListener(\"mousemove\",handleGlobalMove);window.removeEventListener(\"mouseup\",handleGlobalEnd);window.removeEventListener(\"touchmove\",handleGlobalMove);window.removeEventListener(\"touchend\",handleGlobalEnd);};},[isDragging,dragStart,containerWidth,contentWidth,controls]);return /*#__PURE__*/_jsxs(\"div\",{ref:containerRef,style:{width:\"100%\",height:\"100%\",overflow:clipping===\"visible\"?\"visible\":\"hidden\",position:\"relative\",cursor:isDragging?\"grabbing\":\"grab\"},onMouseEnter:handleMouseEnter,onMouseLeave:handleMouseLeave,children:[clipping===\"fade\"&&/*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",left:0,top:0,width:`${fadeWidth}px`,height:\"100%\",background:\"linear-gradient(to right, rgba(255,255,255,1), rgba(255,255,255,0))\",pointerEvents:\"none\",zIndex:1}}),/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",right:0,top:0,width:`${fadeWidth}px`,height:\"100%\",background:\"linear-gradient(to left, rgba(255,255,255,1), rgba(255,255,255,0))\",pointerEvents:\"none\",zIndex:1}})]}),/*#__PURE__*/_jsx(motion.div,{ref:contentRef,animate:controls,style:{display:\"flex\",gap:`${gap}px`,position:\"absolute\",left:0,top:0,height:\"100%\",alignItems:\"center\",userSelect:\"none\"},onMouseDown:handleDragStart,onTouchStart:handleDragStart,children:children})]});}addPropertyControls(Ticker,{children:{type:ControlType.Array,control:{type:ControlType.ComponentInstance},maxCount:20},speed:{type:ControlType.Number,title:\"Speed\",defaultValue:50,min:10,max:200,step:10,unit:\"px/s\"},gap:{type:ControlType.Number,title:\"Gap\",defaultValue:20,min:0,max:100,step:5,unit:\"px\"},direction:{type:ControlType.Enum,title:\"Direction\",options:[\"left\",\"right\"],optionTitles:[\"Left\",\"Right\"],defaultValue:\"left\",displaySegmentedControl:true},pauseOnHover:{type:ControlType.Boolean,title:\"Pause on Hover\",defaultValue:true,enabledTitle:\"Yes\",disabledTitle:\"No\"},clipping:{type:ControlType.Enum,title:\"Clipping\",options:[\"hidden\",\"visible\",\"fade\"],optionTitles:[\"Hidden\",\"Visible\",\"Fade\"],defaultValue:\"hidden\",displaySegmentedControl:true},fadeWidth:{type:ControlType.Number,title:\"Fade Width\",defaultValue:50,min:10,max:200,step:10,unit:\"px\",hidden:({clipping})=>clipping!==\"fade\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"Ticker\",\"slots\":[\"children\"],\"annotations\":{\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Ticker.map"],"mappings":"+QAIG,SAAwB,EAAO,EAAM,CAAC,GAAK,CAAC,WAAS,QAA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