{"version":3,"file":"SmoothScroll_Prod.Dc8ic7H4.mjs","names":["_Fragment"],"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":"sXAGG,SAAwB,EAAa,EAAM,CAAC,GAAK,CAAC,YAAU,CAAC,EAAY,EAAM,EAAO,KAAK,CA8DuxB,MA9DtxB,GAAU,IAAI,CAAC,AAAG,EAAM,SAAQ,EAAM,QAAQ,SAAS,EAAE,CAAC,WAAU,CAAK,EAAC,AAAE,EAAC,CAAC,CAAM,EAAC,CACpL,EAAU,IAAI,CAAC,IAAM,EAAe,SAAS,eAAe,UAAU,CAAC,GAAG,EAAe,CAAC,IAAM,EAAc,IAAI,CAAC,IAAM,EAAU,EAAO,iBAAiB,SAAS,gBAAgB,CAAO,EAAiB,EAAU,WAAW,SAAS,AAAG,GAAkB,EAAe,aAAa,qBAAqB,OAAO,AAAG,EACpT,EAAa,IAAI,iBAAiB,GAAW,CAAC,IAAI,IAAM,KAAY,EAAW,AAAG,EAAS,OAAO,cAAc,EAAS,gBAAgB,SAAS,GAAe,AAAI,GAE3J,MADhB,GAAa,QAAQ,SAAS,gBAAgB,CAAC,YAAW,EAAK,gBAAgB,CAAC,OAAQ,CAAC,EAAC,CAC1F,GAAe,CAAO,IAAI,CAAC,EAAa,YAAY,AA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