{"version":3,"file":"SmoothScroll_Prod.CAgSW03m.mjs","names":["useRef","_Fragment"],"sources":["https:/framerusercontent.com/modules/Yppqt3Cs3Y8TZqvASnXl/TXhR1VriQwDbYQl0Jpzg/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]);// Watch for stop scroll elements\nuseEffect(()=>{const checkForStopScroll=()=>{const stopScrollElement=document.querySelector(\"[data-frameruni-stop-scroll]\");const htmlElement=document.documentElement;const hasHiddenOverflow=htmlElement.style.overflow===\"hidden\";if(lenis.current){if(stopScrollElement||hasHiddenOverflow){lenis.current.stop();}else{lenis.current.start();}}};// Initial check\ncheckForStopScroll();// Set up observers\nconst stopScrollObserver=new MutationObserver(checkForStopScroll);const htmlStyleObserver=new MutationObserver(checkForStopScroll);// Observe document for data-frameruni-stop-scroll attribute\nstopScrollObserver.observe(document.documentElement,{childList:true,subtree:true,attributes:true,attributeFilter:[\"data-frameruni-stop-scroll\"]});// Observe only the HTML element for style changes\nhtmlStyleObserver.observe(document.documentElement,{attributes:true,attributeFilter:[\"style\"]});return()=>{stopScrollObserver.disconnect();htmlStyleObserver.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);};},[]);//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(element=>{const anchor=element;// Only handle internal anchor links\nconst isInternalLink=anchor.href.startsWith(window.location.origin)||anchor.href.startsWith(\"./\")||anchor.href.startsWith(\"/\");const hasHash=anchor.href.includes(\"#\");return isInternalLink&&hasHash;}).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\":\"Smo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