{"version":3,"file":"ScrollController.D43LnccM.mjs","names":["useRef"],"sources":["https:/framerusercontent.com/modules/ZJOfsTKS4GabSwgvfgxs/U8GxtljWsYMQ7IlkKqWx/ScrollController.js"],"sourcesContent":["// Smooth Scroll Controller - Controls scroll speed and smoothness for the page\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useRef}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * @framerIntrinsicWidth 20\n * @framerIntrinsicHeight 20\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight fixed\n */export default function ScrollController(props){const{scrollSpeed=1,smoothness=.1,intensity=1,enabled=true}=props;const scrollContainerRef=useRef(null);const targetScrollRef=useRef(0);const currentScrollRef=useRef(0);const rafRef=useRef();const isAnimatingRef=useRef(false);const lastScrollTimeRef=useRef(0);useEffect(()=>{if(!enabled||typeof window===\"undefined\")return;const handleWheel=e=>{if(typeof window===\"undefined\")return;const maxScroll=document.documentElement.scrollHeight-window.innerHeight;// Check if we're at boundaries\nconst atTop=window.scrollY<=0&&e.deltaY<0;const atBottom=window.scrollY>=maxScroll-1&&e.deltaY>0;if(atTop||atBottom){return;// Allow native scroll at boundaries\n}e.preventDefault();e.stopPropagation();lastScrollTimeRef.current=Date.now();const delta=e.deltaY*scrollSpeed*intensity;targetScrollRef.current+=delta;targetScrollRef.current=Math.max(0,Math.min(targetScrollRef.current,maxScroll));if(!isAnimatingRef.current){isAnimatingRef.current=true;rafRef.current=requestAnimationFrame(animate);}};const animate=()=>{if(typeof window===\"undefined\")return;const diff=targetScrollRef.current-currentScrollRef.current;currentScrollRef.current+=diff*smoothness;if(Math.abs(diff)>.1){window.scrollTo(0,currentScrollRef.current);rafRef.current=requestAnimationFrame(animate);}else{window.scrollTo(0,targetScrollRef.current);currentScrollRef.current=targetScrollRef.current;isAnimatingRef.current=false;}};const initScroll=()=>{if(typeof window===\"undefined\")return;targetScrollRef.current=window.scrollY;currentScrollRef.current=window.scrollY;};// Detect external scroll changes (like anchor links)\nconst handleScroll=()=>{if(typeof window===\"undefined\")return;// If we haven't scrolled via wheel in the last 100ms, this is an external scroll\nconst timeSinceLastWheel=Date.now()-lastScrollTimeRef.current;const scrollDiff=Math.abs(window.scrollY-targetScrollRef.current);// If enough time has passed OR there's a significant difference in scroll position\n// (like from an anchor link), sync our refs\nif(timeSinceLastWheel>100||scrollDiff>50){targetScrollRef.current=window.scrollY;currentScrollRef.current=window.scrollY;// Stop any ongoing animation\nif(rafRef.current){cancelAnimationFrame(rafRef.current);rafRef.current=undefined;}isAnimatingRef.current=false;}};initScroll();// Use capture phase to intercept before other handlers\nwindow.addEventListener(\"wheel\",handleWheel,{passive:false,capture:true});window.addEventListener(\"scroll\",handleScroll,{passive:true});return()=>{window.removeEventListener(\"wheel\",handleWheel,{capture:true});window.removeEventListener(\"scroll\",handleScroll);if(rafRef.current){cancelAnimationFrame(rafRef.current);}isAnimatingRef.current=false;};},[scrollSpeed,smoothness,intensity,enabled]);return /*#__PURE__*/_jsx(\"div\",{ref:scrollContainerRef,style:{...props.style,position:\"relative\",width:\"100%\",height:\"100%\",minWidth:20,minHeight:20,pointerEvents:\"none\",opacity:0}});}addPropertyControls(ScrollController,{enabled:{type:ControlType.Boolean,title:\"Enabled\",defaultValue:true,enabledTitle:\"On\",disabledTitle:\"Off\"},scrollSpeed:{type:ControlType.Number,title:\"Scroll Speed\",defaultValue:1,min:.1,max:3,step:.1},smoothness:{type:ControlType.Number,title:\"Smoothness\",defaultValue:.1,min:.01,max:.5,step:.01},intensity:{type:ControlType.Number,title:\"Intensity\",defaultValue:1,min:.1,max:5,step:.1}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ScrollController\",\"slots\":[],\"annotations\":{\"framerIntrinsicWidth\":\"20\",\"framerSupportedLayoutHeight\":\"fixed\",\"framerIntrinsicHeight\":\"20\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"fixed\"}},\"__FramerMetadata__\":{\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