{"version":3,"file":"ScrollSpeed.DtSmFiFr.mjs","names":["React.useRef","React.useState"],"sources":["https:/framerusercontent.com/modules/fKJLgD2zD921URljwTrs/F1txGoINvzuqSbCa79iQ/ScrollSpeed.js"],"sourcesContent":["// ScrollSpeed.tsx\nimport{jsx as _jsx}from\"react/jsx-runtime\";import*as React from\"react\";import{Frame,addPropertyControls,ControlType,RenderTarget}from\"framer\";// Simple clamp helper\nfunction clamp(v,min,max){return Math.min(max,Math.max(min,v));}export function ScrollSpeed(props){const{scrollSpeed,image,fillType,...rest}=props;const ref=React.useRef(null);const[offset,setOffset]=React.useState(0);const isCanvas=RenderTarget.current()===RenderTarget.canvas;// 0–200% → factor 0.5–2, where 100% = 1x (no extra parallax)\nconst clampedSpeed=clamp(scrollSpeed,0,200);const factor=clampedSpeed>=100?clampedSpeed/100:.5+clampedSpeed/100*.5;// Parallax is the difference from normal scroll (1x)\nconst parallaxFactor=factor-1;const sectionRef=React.useRef({start:0,end:0,ready:false});React.useEffect(()=>{if(typeof window===\"undefined\"||isCanvas)return;function measure(){const el=ref.current;if(!el)return;const rect=el.getBoundingClientRect();const scrollY=window.scrollY||window.pageYOffset;const vh=window.innerHeight||document.documentElement.clientHeight;const top=rect.top+scrollY;const height=rect.height;// Start before it enters, end after it leaves viewport\nconst start=top-vh;const end=top+height+vh;sectionRef.current={start,end,ready:true};}function onScroll(){if(!sectionRef.current.ready)return;const scrollY=window.scrollY||window.pageYOffset;const{start,end}=sectionRef.current;// Before active range\nif(scrollY<=start){setOffset(0);return;}const total=end-start;// After active range\nif(scrollY>=end){setOffset(total*parallaxFactor);return;}// Inside active range\nconst local=scrollY-start;setOffset(local*parallaxFactor);}measure();onScroll();window.addEventListener(\"scroll\",onScroll,{passive:true});window.addEventListener(\"resize\",measure);return()=>{window.removeEventListener(\"scroll\",onScroll);window.removeEventListener(\"resize\",measure);};},[parallaxFactor,isCanvas]);// Background image styles\nlet backgroundImage;let backgroundSize;let backgroundRepeat=\"no-repeat\";let backgroundPosition=\"center\";if(image){backgroundImage=`url(${image})`;switch(fillType){case\"fit\":backgroundSize=\"contain\";break;case\"stretch\":backgroundSize=\"100% 100%\";break;case\"tile\":backgroundSize=\"auto\";backgroundRepeat=\"repeat\";backgroundPosition=\"top left\";break;case\"fill\":default:backgroundSize=\"cover\";break;}}return /*#__PURE__*/_jsx(Frame,{...rest,ref:ref,size:\"100%\",// Base parallax position (no movement in Canvas)\ny:isCanvas?0:offset,style:{width:\"100%\",height:\"100%\",backgroundImage,backgroundSize,backgroundRepeat,backgroundPosition}});}// Defaults\nScrollSpeed.defaultProps={scrollSpeed:100,image:undefined,fillType:\"fill\",width:300,height:300};addPropertyControls(ScrollSpeed,{// Scroll [Scroll speed]\nscrollSpeed:{type:ControlType.Number,title:\"Scroll speed\",min:0,max:200,step:1,unit:\"%\",defaultValue:100},// (Image)\nimage:{type:ControlType.Image,title:\"Image\"},fillType:{type:ControlType.Enum,title:\"Type\",options:[\"fill\",\"fit\",\"stretch\",\"tile\"],optionTitles:[\"Fill\",\"Fit\",\"Stretch\",\"Tile\"]}});\nexport const __FramerMetadata__ = {\"exports\":{\"ScrollSpeed\":{\"type\":\"reactComponent\",\"name\":\"ScrollSpeed\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ScrollSpeed.map"],"mappings":"+MAEA,SAAS,EAAM,EAAE,EAAI,EAAI,CAAC,OAAO,KAAK,IAAI,EAAI,KAAK,IAAI,EAAI,EAAE,CAAC,CAAE,SAAgB,EAAY,EAAM,CAAC,GAAK,CAAC,cAAY,QAAM,WAAS,GAAG,GAAM,EAAY,EAAIA,EAAa,KAAK,CAAM,CAAC,EAAO,GAAWC,EAAe,EAAE,CAAO,EAAS,EAAa,SAAS,GAAG,EAAa,OACzQ,EAAa,EAAM,EAAY,EAAE,IAAI,CACrC,GADmD,GAAc,IAAI,EAAa,IAAI,GAAG,EAAa,IAAI,IACpF,EA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