{"version":3,"file":"HorizontalScroller.BkJbBiJ5.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/W5bVGd7Xkzj5pdlHdVI1/dBKJNqR7LVVymnyqLTcY/HorizontalScroller.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useLayoutEffect,useRef,useState}from\"react\";import{motion,useScroll,useSpring,useTransform}from\"framer-motion\";/**\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight auto\n *\n * @framerIntrinsicWidth 800\n * @framerIntrinsicHeight 400\n *\n * @framerDisableUnlink\n */export default function HorizontalScroller(props){const stickyTop=props.top;const containerOverflow=props.overflow;const containerRef=useRef(null);const scrollRef=useRef(null);const sizerRef=useRef(null);const[scrollRange,setScrollRange]=useState(0);const[contentWidth,setContentWidth]=useState(0);useLayoutEffect(()=>{setScrollRange(scrollRef.current.scrollWidth);const onResize=entries=>{for(let entry of entries){setContentWidth(entry.contentRect.width);setScrollRange(scrollRef.current.scrollWidth);}};const onStyleChange=entries=>{for(let entry of entries){setScrollRange(scrollRef.current.scrollWidth);}};const resizeObserver=new ResizeObserver(onResize);resizeObserver.observe(sizerRef.current);const mutationObserver=new MutationObserver(onStyleChange);mutationObserver.observe(scrollRef.current,{attributes:true,attributeFilter:[\"style\"]});return()=>{resizeObserver.disconnect();mutationObserver.disconnect();};},[]);const{scrollYProgress}=useScroll({target:containerRef});const transform=useTransform(scrollYProgress,[0,1],[0,-scrollRange+contentWidth]);const physics={damping:60,mass:1,stiffness:500};const spring=useSpring(transform,physics);return /*#__PURE__*/_jsxs(\"div\",{ref:containerRef,...props,children:[/*#__PURE__*/_jsx(\"div\",{style:{position:\"sticky\",top:stickyTop},children:/*#__PURE__*/_jsx(\"div\",{style:{overflow:containerOverflow},children:/*#__PURE__*/_jsx(motion.div,{ref:scrollRef,style:{x:spring},children:props.children})})}),/*#__PURE__*/_jsx(\"div\",{ref:sizerRef,\"aria-hidden\":\"true\",style:{width:\"100%\",height:scrollRange}})]});}HorizontalScroller.displayName=\"Horizontal Scroller\";addPropertyControls(HorizontalScroller,{branding:{type:ControlType.Enum,title:\"Developed By\",options:[\"artech\"],optionTitles:[\"artech\"],displaySegmentedControl:true,description:\"Live [demo](https://horizontalscroller.framer.website).\"},children:{type:ControlType.ComponentInstance,title:\"Frame\",description:\"Long, overflowing frame.\"},top:{type:ControlType.Number,title:\"Top\",description:\"Auto sticky.\\n\\n*Note*: Parent containers require their overflows set to clip for sticky to work.\",defaultValue:0,min:0,step:1,displayStepper:true},overflow:{type:ControlType.Enum,defaultValue:\"hidden\",displaySegmentedControl:true,segmentedControlDirection:\"horizontal\",options:[\"hidden\",\"visible\"],optionTitles:[\"Hidden\",\"Visible\"]}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"HorizontalScroller\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"auto\",\"framerIntrinsicWidth\":\"800\",\"framerDisableUnlink\":\"\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerIntrinsicHeight\":\"400\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./HorizontalScroller.map"],"mappings":"wQAQG,SAAwB,EAAmB,EAAM,CAAC,IAAM,EAAU,EAAM,IAAU,EAAkB,EAAM,SAAe,EAAaA,EAAO,IAAI,EAAQ,EAAUA,EAAO,IAAI,EAAQ,EAASA,EAAO,IAAI,EAAO,CAAC,EAAY,GAAgBC,EAAS,CAAC,EAAO,CAAC,EAAa,GAAiBA,EAAS,CAAC,EAAE,MAAoB,CAAC,EAAe,EAAU,QAAQ,WAAW,EAAE,IAAM,EAAS,GAAS,CAAC,IAAI,IAAI,KAAS,EAAS,EAAgB,EAAM,YAAY,KAAK,EAAE,EAAe,EAAU,QAAQ,WAAW,CAAG,EAAQ,EAAc,GAAS,CAAC,IAAI,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