{"version":3,"file":"ScrollBlur.CHP85W9f.mjs","names":["useState","useRef"],"sources":["https:/framerusercontent.com/modules/3OEbnaDsj6XU8xqUNF0I/E8KaMA4Pcbb8SHDDcB6q/ScrollBlur.js"],"sourcesContent":["// Dynamic background blur for top/bottom edges, fading softly to the middle, responsive to scroll speed, with adjustable zones, intensity, sensitivity, and tint.\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useRef,useState,startTransition}from\"react\";import{addPropertyControls,ControlType,RenderTarget,useIsStaticRenderer}from\"framer\";function clamp(val,min,max){return Math.max(min,Math.min(max,val));}/**\n * ScrollBlur\n *\n * Adds a dynamic background blur to the top and/or bottom edges of the screen, fading softly to the middle, responsive to scroll speed.\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n * @framerIntrinsicWidth 40\n * @framerIntrinsicHeight 40\n */export default function ScrollBlur(props){const{applyTo,topSize,bottomSize,maxBlur,sensitivity,tintColor,style}=props;const[blur,setBlur]=useState(0);const lastScrollY=useRef(0);const lastTimestamp=useRef(0);const fadeTimeout=useRef(null);const isStatic=useIsStaticRenderer();useEffect(()=>{if(isStatic||typeof window===\"undefined\")return;let ticking=false;let lastBlur=0;let fadeRAF=null;function fadeBlur(){// Instantly set blur to 0\nlastBlur=0;startTransition(()=>setBlur(0));fadeRAF=null;}function onScroll(){if(!ticking){window.requestAnimationFrame(()=>{const now=performance.now();const y=window.scrollY;const dt=now-(lastTimestamp.current||now);const dy=y-lastScrollY.current;lastScrollY.current=y;lastTimestamp.current=now;const speed=Math.abs(dy)/(dt||1);const blurValue=clamp(speed*maxBlur*(sensitivity||1),0,maxBlur);lastBlur=blurValue;startTransition(()=>setBlur(blurValue));if(fadeRAF)cancelAnimationFrame(fadeRAF);if(fadeTimeout.current)clearTimeout(fadeTimeout.current);fadeTimeout.current=setTimeout(()=>{fadeRAF=requestAnimationFrame(fadeBlur);},80);ticking=false;});ticking=true;}}window.addEventListener(\"scroll\",onScroll,{passive:true});// Trigger blur on initial mount if already scrolling\nif(window.scrollY!==0)onScroll();return()=>{window.removeEventListener(\"scroll\",onScroll);if(fadeTimeout.current)clearTimeout(fadeTimeout.current);if(fadeRAF)cancelAnimationFrame(fadeRAF);};},[maxBlur,sensitivity,isStatic]);if(RenderTarget.current()===RenderTarget.thumbnail||isStatic)return null;// Soft fade mask for blur: fade to transparent at the middle of the blur zone\nfunction getMask(position){if(position===\"top\"){// Smoother, longer fade, no visible edge\nreturn`linear-gradient(to bottom, black 0%, black 60%, rgba(0,0,0,0.5) 80%, transparent 100%)`;}else{return`linear-gradient(to top, black 0%, black 60%, rgba(0,0,0,0.5) 80%, transparent 100%)`;}}// Blur layer style\nconst blurLayer=(position,size)=>/*#__PURE__*/_jsx(\"div\",{\"aria-hidden\":\"true\",style:{pointerEvents:\"none\",position:\"fixed\",left:0,[position]:0,width:\"100vw\",height:`calc(${size}vh)`,zIndex:9999,backdropFilter:`blur(${blur}px)`,WebkitBackdropFilter:`blur(${blur}px)`,background:tintColor?`linear-gradient(to ${position===\"top\"?\"bottom\":\"top\"}, ${tintColor} 0%, transparent 100%)`:undefined,transition:\"backdrop-filter 0.25s, -webkit-backdrop-filter 0.25s, opacity 0.7s cubic-bezier(.4,0,.2,1)\",opacity:blur>0?Math.min(1,blur/(maxBlur*.7)):0,willChange:\"backdrop-filter, opacity\",maskImage:getMask(position),WebkitMaskImage:getMask(position)}});return /*#__PURE__*/_jsxs(\"div\",{style:{position:\"relative\",minWidth:5,minHeight:5,width:\"100%\",height:\"100%\"},children:[(applyTo===\"top\"||applyTo===\"both\")&&topSize>0&&blurLayer(\"top\",topSize),(applyTo===\"bottom\"||applyTo===\"both\")&&bottomSize>0&&blurLayer(\"bottom\",bottomSize)]});}addPropertyControls(ScrollBlur,{applyTo:{type:ControlType.Enum,title:\"Apply To\",options:[\"top\",\"bottom\",\"both\"],optionTitles:[\"Top\",\"Bottom\",\"Both\"],defaultValue:\"both\",displaySegmentedControl:true},topSize:{type:ControlType.Number,title:\"Top Size\",defaultValue:10,min:1,max:50,step:.1,unit:\"%\",hidden:({applyTo})=>applyTo===\"bottom\"},bottomSize:{type:ControlType.Number,title:\"Bottom Size\",defaultValue:10,min:1,max:50,step:.1,unit:\"%\",hidden:({applyTo})=>applyTo===\"top\"},maxBlur:{type:ControlType.Number,title:\"Max Blur\",defaultValue:32,min:1,max:10,step:1,unit:\"px\"},sensitivity:{type:ControlType.Number,title:\"Sensitivity\",defaultValue:.5,min:.01,max:1,step:.01},tintColor:{type:ControlType.Color,title:\"Tint Color\",defaultValue:\"rgba(255,255,255,0.12)\",optional:true}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ScrollBlur\",\"slots\":[],\"annotations\":{\"framerIntrinsicHeight\":\"40\",\"framerIntrinsicWidth\":\"40\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ScrollBlur.map"],"mappings":"mXAC2M,SAAS,EAAM,EAAI,EAAI,EAAI,CAAC,OAAO,KAAK,IAAI,EAAI,KAAK,IAAI,EAAI,EAAI,CAAC,CAS1Q,SAAwB,EAAW,EAAM,CAAC,GAAK,CAAC,UAAQ,UAAQ,aAAW,UAAQ,cAAY,YAAU,SAAO,EAAW,CAAC,EAAK,GAASA,EAAS,EAAE,CAAO,EAAYC,EAAO,EAAE,CAAO,EAAcA,EAAO,EAAE,CAAO,EAAYA,EAAO,KAAK,CAAO,EAAS,GAAqB,CAEtD,GAFuD,MAAc,CAAC,GAAG,GAAiB,IAAS,OAAY,OAAO,IAAI,EAAQ,GAAyB,EAAQ,KAAK,SAAS,GAAU,CAChZ,MAAoB,EAAQ,EAAE,CAAC,CAAC,EAAQ,KAAM,SAAS,GAAU,CAAC,AAA4jB,KAA/iB,EAAO,0BAA0B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