{"version":3,"file":"LoopingScrollWrapper.Dj2koKbc.mjs","names":["useRef","Children"],"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":"0MAOG,SAAwB,EAAqB,EAAM,CAAC,GAAK,CAAC,WAAS,YAAU,aAAa,YAAU,IAAI,OAAK,GAAK,aAAW,SAAS,iBAAe,cAAc,EAAY,EAAaA,EAAO,IAAI,EAAQ,EAAeA,EAAO,EAAK,EAAQ,EAAWA,EAAO,IAAI,EAAQ,EAAa,IAAY,aAAmB,EAAY,EAAK,EAAE,EAAE,MAAc,CAAC,IAAM,EAAU,EAAa,QAAQ,GAAG,CAAC,GAAW,CAAC,EAAK,OAAO,IAAM,MAAiB,CAAC,GAAG,EAAe,QAAQ,OAAO,IAAM,E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