{"version":3,"file":"LoopingScrollWrapper.K6-p9ptS.mjs","names":["useRef"],"sources":["https:/framerusercontent.com/modules/merxZTQxDcnVSncQZfXU/zZivIte6dWSGIOk5LDHe/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}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}=props;const containerRef=useRef(null);const isResettingRef=useRef(false);const rafRef=useRef();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\nsetTimeout(setInitialPosition,50);return()=>{container.removeEventListener(\"scroll\",handleScroll);if(rafRef.current){cancelAnimationFrame(rafRef.current);}};},[direction,threshold,isHorizontal,children,loop]);// Create repeated children\nconst repeatedChildren=Array.from({length:repeatCount},(_,index)=>/*#__PURE__*/_jsx(\"div\",{style:{display:\"flex\",flexDirection:isHorizontal?\"row\":\"column\",flexShrink:0},children:children},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?\"max-content\":\"100%\",height:isHorizontal?\"100%\":\"max-content\",alignItems:props.alignItems,justifyContent:props.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\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\",\"framerIntrinsicWidth\":\"400\",\"framerIntrinsicHeight\":\"300\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./LoopingScrollWrapper.map"],"mappings":"iLAOG,SAAwB,EAAqB,EAAM,CAAC,GAAK,CAAC,WAAS,YAAU,aAAa,YAAU,IAAI,OAAK,IAAM,EAAY,EAAaA,EAAO,KAAK,CAAO,EAAeA,EAAO,GAAM,CAAO,EAAOA,GAAQ,CAAO,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,EAAU,EAAa,EAAU,WAAW,EAAU,UAAgB,EAAW,EAAa,EAAU,YAAY,EAAU,aAAmB,EAAW,EAAa,EAAU,YAAY,EAAU,aAC9mB,EAAe,EAAW,EAChC,GAAG,GAAgB,EAAW,OAAO,IAAM,EAAU,EAAW,EAChE,GAAG,GAAW,EAAU,EAAU,CAClC,EAAe,QAAQ,GAAqD,IAAM,EAAY,EAA3C,EAAU,EAAoE,EAAc,EAAU,WAAW,EAAkB,EAAU,UAAU,EAAa,0BAA0B,CAAC,EAAe,QAAQ,IAAQ,SAAU,GAAW,EAAU,CAChT,EAAe,QAAQ,GAAK,IAAM,EAAiB,EAAU,EAAqB,EAAY,EAAU,EAAe,EAAoB,EAAc,EAAU,WAAW,EAAkB,EA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