{"version":3,"file":"LoopingScrollWrapper.CEbhlukz.mjs","names":["useRef","Children","__esmMin","z","init_ssg_sandbox_shims","j","de","K","init_npm_react_18_3_1","ce","window","init_framer_BL70qLPA","addPropertyControls","ControlType","LoopingScrollWrapper","props","containerRef","isResettingRef","timeoutRef","isHorizontal","direction","repeatCount","loop","container","handleScroll","scrollPos","scrollSize","clientSize","singleItemSize","maxScroll","threshold","newPosition","offsetWithinItem","middlePosition","children","fillWidthChildren","child","childStyle","repeatedChildren","index","init_LoopingScrollWrapper","init_jsx_runtime"],"sources":["https:/framerusercontent.com/modules/x0Qp7wDy2sfXkLCU6GnE/8dlwTQjdsk0vTrkd1ssl/LoopingScrollWrapper.js"],"sourcesContent":["// LoopingScrollWrapper - A container that enables seamless infinite scrolling in horizontal or vertical directions\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useRef,useEffect,Children,cloneElement,isValidElement}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * @framerIntrinsicWidth 400\n * @framerIntrinsicHeight 300\n * \n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function LoopingScrollWrapper(props){const{children,direction=\"horizontal\",threshold=100,loop=true,alignItems=\"center\",justifyContent=\"flex-start\"}=props;const containerRef=useRef(null);const isResettingRef=useRef(false);const timeoutRef=useRef(null);const isHorizontal=direction===\"horizontal\";const repeatCount=loop?5:1;useEffect(()=>{const container=containerRef.current;if(!container||!loop)return;const handleScroll=()=>{if(isResettingRef.current)return;const scrollPos=isHorizontal?container.scrollLeft:container.scrollTop;const scrollSize=isHorizontal?container.scrollWidth:container.scrollHeight;const clientSize=isHorizontal?container.clientWidth:container.clientHeight;// Calculate single item size\nconst singleItemSize=scrollSize/repeatCount;// If content is smaller than container, no need to loop\nif(singleItemSize<=clientSize)return;const maxScroll=scrollSize-clientSize;// Reset when approaching boundaries\nif(scrollPos>=maxScroll-threshold){// Near end - jump to beginning + current offset within item\nisResettingRef.current=true;const offsetWithinItem=scrollPos%singleItemSize;const newPosition=singleItemSize+offsetWithinItem;if(isHorizontal){container.scrollLeft=newPosition;}else{container.scrollTop=newPosition;}requestAnimationFrame(()=>{isResettingRef.current=false;});}else if(scrollPos<=threshold){// Near beginning - jump to end - current offset\nisResettingRef.current=true;const offsetWithinItem=scrollPos%singleItemSize;const newPosition=maxScroll-singleItemSize+offsetWithinItem;if(isHorizontal){container.scrollLeft=newPosition;}else{container.scrollTop=newPosition;}requestAnimationFrame(()=>{isResettingRef.current=false;});}};container.addEventListener(\"scroll\",handleScroll,{passive:true});// Set initial position to middle\nconst setInitialPosition=()=>{const scrollSize=isHorizontal?container.scrollWidth:container.scrollHeight;const clientSize=isHorizontal?container.clientWidth:container.clientHeight;const singleItemSize=scrollSize/repeatCount;if(singleItemSize>clientSize){const middlePosition=singleItemSize*2;if(isHorizontal){container.scrollLeft=middlePosition;}else{container.scrollTop=middlePosition;}}};// Set initial position after render\nif(typeof window!==\"undefined\"){timeoutRef.current=window.setTimeout(setInitialPosition,50);}return()=>{container.removeEventListener(\"scroll\",handleScroll);if(timeoutRef.current!=null&&typeof window!==\"undefined\"){window.clearTimeout(timeoutRef.current);}};},[direction,threshold,isHorizontal,children,loop]);const fillWidthChildren=Children.map(children,child=>{if(!/*#__PURE__*/isValidElement(child))return child;const childStyle=child.props?.style||{};return /*#__PURE__*/cloneElement(child,{style:{...childStyle,width:\"100%\",minWidth:\"100%\",flex:\"1 1 100%\"}});});// Create repeated children\nconst repeatedChildren=Array.from({length:repeatCount},(_,index)=>/*#__PURE__*/_jsx(\"div\",{style:{display:\"flex\",flexDirection:isHorizontal?\"row\":\"column\",flexShrink:0,...isHorizontal?{width:\"100%\",minWidth:\"100%\",flex:\"0 0 100%\"}:{width:\"100%\"}},children:/*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",minWidth:\"100%\",flexShrink:0,...isHorizontal?{flex:\"0 0 100%\"}:{}},children:fillWidthChildren})},index));return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:{...props.style,position:\"relative\",width:\"100%\",height:\"100%\",overflow:\"auto\",WebkitOverflowScrolling:\"touch\",scrollBehavior:\"auto\"},children:/*#__PURE__*/_jsx(\"div\",{style:{display:\"flex\",flexDirection:isHorizontal?\"row\":\"column\",width:isHorizontal?`${repeatCount*100}%`:\"100%\",height:isHorizontal?\"100%\":\"max-content\",alignItems,justifyContent},children:repeatedChildren})});}addPropertyControls(LoopingScrollWrapper,{children:{type:ControlType.Slot,title:\"Content\"},loop:{type:ControlType.Boolean,title:\"Loop\",defaultValue:true,enabledTitle:\"On\",disabledTitle:\"Off\"},direction:{type:ControlType.Enum,title:\"Direction\",options:[\"horizontal\",\"vertical\"],optionTitles:[\"Horizontal\",\"Vertical\"],defaultValue:\"horizontal\"},alignItems:{type:ControlType.Enum,title:\"Align\",options:[\"flex-start\",\"center\",\"flex-end\",\"stretch\"],optionTitles:[\"Start\",\"Center\",\"End\",\"Stretch\"],defaultValue:\"center\"},justifyContent:{type:ControlType.Enum,title:\"Justify\",options:[\"flex-start\",\"center\",\"flex-end\",\"space-between\",\"space-around\",\"space-evenly\"],optionTitles:[\"Start\",\"Center\",\"End\",\"Between\",\"Around\",\"Evenly\"],defaultValue:\"flex-start\"},threshold:{type:ControlType.Number,title:\"Threshold\",defaultValue:100,min:10,max:500,step:10,unit:\"px\",hidden:({loop})=>!loop}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"LoopingScrollWrapper\",\"slots\":[\"children\"],\"annotations\":{\"framerSupportedLayoutWidth\":\"any\",\"framerContractVersion\":\"1\",\"framerIntrinsicWidth\":\"400\",\"framerIntrinsicHeight\":\"300\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./LoopingScrollWrapper.map"],"mappings":"A,0MAOG,SAAwBc,EAAqB,EAAM,CAAC,GAAK,CAAC,WAAS,YAAU,aAAa,YAAU,IAAI,OA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