{"version":3,"file":"SmoothScroll_Prod.DvHeTLkB.mjs","names":["useRef","_Fragment","__esmMin","init_npm_react_18_3_1","init_ssg_sandbox_shims","window","l","c","init_jsx_runtime","ce","de","addPropertyControls","init_framer_BWFVvmND","ControlType","Lenis","init_lenis","SmoothScroll","props","lenis","overlayElement","checkOverflow","htmlObserver","mutation","mutations","allElements","i","element","intensity","raf","time","styleElement","anchorLinksData","anchor","href","decodedHref","scrollMargin","targetElement","handleClick","handlers","e","anchorElement","index","init_SmoothScroll_Prod"],"sources":["https:/framerusercontent.com/modules/Yppqt3Cs3Y8TZqvASnXl/CzcVr5U1VFk6uNcyYvJq/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]);// Check Overlay overflow\nuseEffect(()=>{const overlayElement=document.getElementById(\"overlay\");if(overlayElement){const checkOverflow=()=>{const htmlStyle=window.getComputedStyle(document.documentElement);const isOverflowHidden=htmlStyle.overflow===\"hidden\";if(isOverflowHidden){overlayElement.setAttribute(\"data-lenis-prevent\",\"true\");}};// Set up MutationObserver for the html element\nconst htmlObserver=new MutationObserver(mutations=>{for(const mutation of mutations){if(mutation.type===\"attributes\"&&mutation.attributeName===\"style\"){checkOverflow();}}});// Observe the html element for style changes\nhtmlObserver.observe(document.documentElement,{attributes:true,attributeFilter:[\"style\"]});// Initial check\ncheckOverflow();return()=>{htmlObserver.disconnect();};}},[]);// useEffect(() => {\n//     const overlayElement = document.getElementById(\"overlay\")\n//     if (overlayElement) {\n//         const handleMutation = (mutationsList, observer) => {\n//             for (const mutation of mutationsList) {\n//                 if (\n//                     mutation.type === \"childList\" &&\n//                     overlayElement.children.length > 0\n//                 ) {\n//                     // Check if the html tag has the style \"overflow: hidden;\"\n//                     const htmlElement = document.documentElement\n//                     console.log(htmlElement, \"htmlElement\")\n//                     const computedStyle =\n//                         window.getComputedStyle(htmlElement)\n//                     console.log(\"computedStyle\", computedStyle)\n//                     const isOverflowHidden =\n//                         computedStyle.overflow === \"hidden\"\n//                     console.log(\"isOverflowHidden\", isOverflowHidden)\n//                     if (isOverflowHidden) {\n//                         overlayElement.setAttribute(\n//                             \"data-lenis-prevent\",\n//                             \"true\"\n//                         )\n//                     }\n//                 }\n//             }\n//         }\n//         const observer = new MutationObserver(handleMutation)\n//         observer.observe(overlayElement, {\n//             childList: true,\n//             attributes: true,\n//             subtree: true,\n//         })\n//         return () => observer.disconnect()\n//     }\n// }, [])\nuseEffect(()=>{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);};},[]);//https://github.com/darkroomengineering/lenis?tab=readme-ov-file#anchor-links\nuseEffect(()=>{// Get all anchor links and store click handlers with their targets\nconst anchorLinksData=[...document.querySelectorAll(\"a[href]\")].filter(anchor=>anchor.href.includes(\"#\")).map(anchor=>{const href=`#${anchor.href.split(\"#\").pop()}`;const decodedHref=decodeURIComponent(href);let scrollMargin=0;const targetElement=document.querySelector(decodedHref);if(targetElement){scrollMargin=parseInt(window.getComputedStyle(targetElement).scrollMarginTop);}return{href,scrollMargin,anchorElement:anchor};});const handleClick=(e,href,scrollMargin)=>{e.preventDefault();lenis.current.scrollTo(href,{offset:-scrollMargin});};const handlers=anchorLinksData.map(({href,scrollMargin})=>e=>handleClick(e,href,scrollMargin));anchorLinksData.forEach(({anchorElement},index)=>{anchorElement.addEventListener(\"click\",handlers[index]);});return()=>{anchorLinksData.forEach(({anchorElement},index)=>{anchorElement.removeEventListener(\"click\",handlers[index]);});};},[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://frameruni.link/cc).\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"SmoothScroll\",\"slots\":[],\"annotations\":{\"framerDisableUnlink\":\"\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./SmoothScroll_Prod.map"],"mappings":"A,2PAGG,SAAwBgB,EAAa,EAAM,CAAC,GAAK,CAAC,aAAWC,EAAYC,EAAMlB,EAAO,IAAI,EA8DwxB,OA9DtxBS,MAAc,CAAIS,EAAM,SAAQA,EAAM,QAAQ,SAAS,EAAE,CAAC,UAAU,EAAI,CAAC,CAAE,EAAE,CAACA,CAAK,CAAC,EACnLT,MAAc,CAAC,IAAMU,EAAe,SAAS,eAAe,SAAS,EAAE,GAAGA,EAAe,CAAC,IAAMC,MAAkB,CAAiBf,EAAO,iBAAiB,SAAS,eAAgD,CAAC,CAAC,WAAW,UAA8Bc,EAAe,aAAa,qBAAqB,MAAM,CAAG,EACnTE,EAAa,IAAI,iBAAiB,G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