{"version":3,"file":"SmoothScroll_Prod.Vr_6o7Tq.mjs","names":["useRef","_Fragment","__esmMin","init_npm_react_18_3_1","window","ce","init_jsx_runtime","c","de","init_ssg_sandbox_shims","addPropertyControls","init_framer_BisrWwwE","ControlType","init_lenis","Lenis","SmoothScroll","props","lenis","overlayElement","observer","mutation","mutationsList","htmlElement","allElements","i","element","intensity","raf","time","styleElement","anchorLinks","handleClick","decodedHref","href","a","l","init_SmoothScroll_Prod"],"sources":["https:/framerusercontent.com/modules/Yppqt3Cs3Y8TZqvASnXl/G8FZBIufdcxDme09PKPy/SmoothScroll_Prod.js"],"sourcesContent":["import{jsx as _jsx,Fragment as _Fragment}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import Lenis from\"lenis\";// import Lenis from \"@studio-freight/lenis\"\nimport{useEffect,useRef}from\"react\";/**\n * @framerDisableUnlink\n */export default function SmoothScroll(props){const{intensity}=props;const lenis=useRef(null);useEffect(()=>{if(lenis.current)lenis.current.scrollTo(0,{immediate:true});},[lenis]);useEffect(()=>{const overlayElement=document.getElementById(\"overlay\");if(overlayElement){const handleMutation=(mutationsList,observer)=>{for(const mutation of mutationsList){if(mutation.type===\"childList\"){const hasChildren=overlayElement.children.length>0;if(hasChildren){// Check if the html tag has the style \"overflow: hidden;\"\nconst htmlElement=document.documentElement;const computedStyle=window.getComputedStyle(htmlElement);const isOverflowHidden=computedStyle.getPropertyValue(\"overflow\")===\"hidden\";if(isOverflowHidden){overlayElement.setAttribute(\"data-lenis-prevent\",\"true\");}}}}};const observer=new MutationObserver(handleMutation);const config={childList:true};observer.observe(overlayElement,config);return()=>observer.disconnect();}},[]);useEffect(()=>{const allElements=document.getElementsByTagName(\"*\");for(let i=0;i<allElements.length;i++){const element=allElements[i];const computedStyle=window.getComputedStyle(element);if(computedStyle.getPropertyValue(\"overflow\")===\"auto\"){element.setAttribute(\"data-lenis-prevent\",\"true\");}}},[]);useEffect(()=>{lenis.current=new Lenis({duration:intensity/10});const raf=time=>{if(lenis.current){lenis.current.raf(time);requestAnimationFrame(raf);}};requestAnimationFrame(raf);return()=>{if(lenis.current){lenis.current.destroy();lenis.current=null;}};},[]);useEffect(()=>{const styleElement=document.createElement(\"style\");styleElement.textContent=`\nhtml.lenis {\nheight: auto;\n}\n.lenis.lenis-smooth {\n\nscroll-behavior: auto !important;\n}\n.lenis.lenis-smooth [data-lenis-prevent] {\n\noverscroll-behavior: contain;\n}\n.lenis.lenis-stopped {\n\noverflow: hidden;\n}\n.lenis.lenis-scrolling iframe {\n\npointer-events: none;\n}\n`;document.head.appendChild(styleElement);return()=>{document.head.removeChild(styleElement);};},[]);useEffect(()=>{const anchorLinks=[...document.querySelectorAll(\"a[href]\")];const handleClick=(e,href)=>{e.preventDefault();const decodedHref=decodeURIComponent(href);lenis.current.scrollTo(decodedHref);};anchorLinks.filter(a=>a.href.includes(\"#\")).forEach(a=>{const href=`#${a.href.split(\"#\").pop()}`;a.addEventListener(\"click\",e=>handleClick(e,href));});return()=>{anchorLinks.filter(a=>a.href.includes(\"#\")).forEach(a=>{const href=`#${a.href.split(\"#\").pop()}`;a.removeEventListener(\"click\",e=>handleClick(e,href));});};},[lenis]);return /*#__PURE__*/_jsx(_Fragment,{});}SmoothScroll.displayName=\"Smooth Scroll\";addPropertyControls(SmoothScroll,{intensity:{title:\"Intensity\",type:ControlType.Number,defaultValue:10,description:\"More components at [Framer University](https://framer.university?utm_source=component).\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"SmoothScroll\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerDisableUnlink\":\"\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./SmoothScroll_Prod.map"],"mappings":"A,sPAGG,SAAwBe,EAAa,EAAM,CAAC,GAAK,CAAC,aAAWC,EAAYC,EAAMjB,EAAO,IAAI,EAqB6hB,OArB3hBK,MAAc,CAAIY,EAAM,SAAQA,EAAM,QAA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