{"version":3,"file":"Scroll_Code.DHSRS4lc.mjs","names":["useRef"],"sources":["https:/framerusercontent.com/modules/Ba19LrnyEQXp4yOeTbiD/YPkzwTw2p7F4Cd9AhKxG/Scroll_Code.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useEffect,useRef}from\"react\";/**\n * Invisible scroll engine — drop anywhere on the page.\n * Each scroll moves exactly one 100vh section.\n *\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n * @framerIntrinsicWidth 1\n * @framerIntrinsicHeight 1\n */export default function ScrollSnapEngine(props){const{sections=5,snapDuration=480,snapCooldown=480,autoPageHeight=true}=props;const progressRef=useRef(0);const isSnappingRef=useRef(false);const snapLockRef=useRef(false);const snapRafRef=useRef(0);const touchStartRef=useRef(null);useEffect(()=>{const snapPoints=sections<=1?[0]:Array.from({length:sections},(_,i)=>i/(sections-1));const getTravel=()=>{const travel=document.documentElement.scrollHeight-window.innerHeight;return travel>0?travel:0;};const syncProgress=()=>{const travel=getTravel();progressRef.current=travel>0?Math.min(1,Math.max(0,window.scrollY/travel)):0;};const getNextSnap=(current,direction)=>{if(direction>0){return snapPoints.find(p=>p>current+.001)??snapPoints.at(-1);}return[...snapPoints].reverse().find(p=>p<current-.001)??snapPoints[0];};const snapTo=target=>{const travel=getTravel();if(!travel||snapLockRef.current)return;cancelAnimationFrame(snapRafRef.current);const destination=travel*target;const startRaw=progressRef.current;const releaseSnapLock=()=>{window.setTimeout(()=>{snapLockRef.current=false;},snapCooldown);};const finishSnap=()=>{window.scrollTo({top:destination,behavior:\"auto\"});progressRef.current=target;isSnappingRef.current=false;releaseSnapLock();};if(Math.abs(target-startRaw)<.001){finishSnap();return;}snapLockRef.current=true;isSnappingRef.current=true;const prefersReducedMotion=window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;if(prefersReducedMotion){finishSnap();return;}const startedAt=performance.now();const animate=now=>{const t=Math.min(1,(now-startedAt)/snapDuration);const nextRaw=startRaw+(target-startRaw)*t;window.scrollTo({top:travel*nextRaw,behavior:\"auto\"});progressRef.current=nextRaw;if(t<1){snapRafRef.current=requestAnimationFrame(animate);return;}finishSnap();};snapRafRef.current=requestAnimationFrame(animate);};const handleWheel=event=>{event.preventDefault();if(snapLockRef.current||isSnappingRef.current)return;if(event.deltaY===0)return;snapTo(getNextSnap(progressRef.current,event.deltaY));};const handleTouchStart=event=>{touchStartRef.current=event.touches[0]?.clientY??null;};const handleTouchEnd=event=>{if(touchStartRef.current===null||snapLockRef.current||isSnappingRef.current){return;}const endY=event.changedTouches[0]?.clientY??touchStartRef.current;const delta=touchStartRef.current-endY;touchStartRef.current=null;if(delta===0)return;snapTo(getNextSnap(progressRef.current,delta));};const handleKeyDown=event=>{if(snapLockRef.current||isSnappingRef.current)return;if([\"ArrowDown\",\"PageDown\",\"Space\"].includes(event.code)){event.preventDefault();snapTo(getNextSnap(progressRef.current,1));}if([\"ArrowUp\",\"PageUp\"].includes(event.code)){event.preventDefault();snapTo(getNextSnap(progressRef.current,-1));}};if(autoPageHeight){document.body.style.minHeight=`${sections*100}vh`;document.documentElement.style.overscrollBehavior=\"none\";document.body.style.overscrollBehavior=\"none\";}syncProgress();window.addEventListener(\"wheel\",handleWheel,{passive:false});window.addEventListener(\"touchstart\",handleTouchStart,{passive:true});window.addEventListener(\"touchend\",handleTouchEnd,{passive:true});window.addEventListener(\"keydown\",handleKeyDown);window.addEventListener(\"resize\",syncProgress);return()=>{cancelAnimationFrame(snapRafRef.current);window.removeEventListener(\"wheel\",handleWheel);window.removeEventListener(\"touchstart\",handleTouchStart);window.removeEventListener(\"touchend\",handleTouchEnd);window.removeEventListener(\"keydown\",handleKeyDown);window.removeEventListener(\"resize\",syncProgress);if(autoPageHeight){document.body.style.minHeight=\"\";document.documentElement.style.overscrollBehavior=\"\";document.body.style.overscrollBehavior=\"\";}};},[sections,snapDuration,snapCooldown,autoPageHeight]);return /*#__PURE__*/_jsx(\"div\",{\"aria-hidden\":true,style:{position:\"fixed\",width:1,height:1,opacity:0,pointerEvents:\"none\",zIndex:-9999}});}addPropertyControls(ScrollSnapEngine,{sections:{type:ControlType.Number,title:\"Sections\",defaultValue:5,min:2,max:20,step:1,displayStepper:true},snapDuration:{type:ControlType.Number,title:\"Snap ms\",defaultValue:480,min:100,max:2e3,step:10,unit:\"ms\"},snapCooldown:{type:ControlType.Number,title:\"Cooldown ms\",defaultValue:480,min:0,max:2e3,step:10,unit:\"ms\"},autoPageHeight:{type:ControlType.Boolean,title:\"Auto Height\",defaultValue:true,enabledTitle:\"On\",disabledTitle:\"Off\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ScrollSnapEngine\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"any\",\"framerContractVersion\":\"1\",\"framerIntrinsicHeight\":\"1\",\"framerIntrinsicWidth\":\"1\",\"framerSupportedLayoutWidth\":\"any\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Scroll_Code.map"],"mappings":"+LAQG,SAAwB,EAAiB,EAAM,CAAC,GAAK,CAAC,WAAS,EAAE,eAAa,IAAI,eAAa,IAAI,iBAAe,IAAM,EAAY,EAAYA,EAAO,CAAC,EAAQ,EAAcA,EAAO,EAAK,EAAQ,EAAYA,EAAO,EAAK,EAAQ,EAAWA,EAAO,CAAC,EAAQ,EAAcA,EAAO,IAAI,EAAi6G,OAA/5G,MAAc,CAAC,IAAM,EAAW,GAAU,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,CAAC,OAAO,CAAQ,GAAG,EAAE,IAAI,GAAG,EAAS,EAAE,EAAQ,MAAc,CAAC,IAAM,EAAO,SAAS,gBAAgB,aAAa,EAAO,YAAY,OAAO,EAAO,EAAE,EAAO,CAAE,EAAQ,MAAiB,CAAC,IAAM,EAAO,EAAU,EAAE,EAAY,QAAQ,EAAO,EAAE,KAAK,IAAI,EAAE,KAAK,IAAI,EA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