Build 580919stable
Module 600761
1,439 characters · in 346c3c1b9086565b.jsDependencies
Source Raw
function(e,t,i){i.d(t,{i:()=>r});var n=i(64700),s=i(688807),l=i(425763);function r(e){let{containerRef:t,itemType:i="WIDGET",edgeDistance:r=130,maxSpeed:a=1700,power:o=2.2}=e,d=(0,n.useRef)(null),c=(0,n.useRef)(0),u=(0,n.useRef)({top:0,bottom:0}),g=(0,n.useRef)(null),m=(0,n.useCallback)(e=>({isDragging:e.isDragging(),clientOffset:e.getClientOffset(),item:e.getItem()}),[]),{isDragging:f,clientOffset:x,item:h}=(0,s.V)(m);(0,n.useEffect)(()=>{g.current=x},[x]);let I=(0,l.VU)();(0,n.useEffect)(()=>{let e=t.current;if(null==e)return;if(!(!0===f&&h?.itemType===i&&!I)){null!==d.current&&cancelAnimationFrame(d.current),d.current=null,e.style.overflowAnchor="auto",e.style.overscrollBehavior="auto",c.current=0;return}let n=e.getBoundingClientRect();return u.current={top:n.top,bottom:n.bottom},e.style.overflowAnchor="none",e.style.overscrollBehavior="contain",d.current=requestAnimationFrame(function t(i){d.current=requestAnimationFrame(t);let n=g.current;if(null==e||null==n){c.current=i;return}let s=Math.min(32,0!==c.current?i-c.current:16)/1e3;c.current=i;let{top:l,bottom:m}=u.current,f=n.y,x=f-l,h=m-f,I=0;if(x>=0&&x<r?I=-a*Math.pow(1-x/r,o):h>=0&&h<r&&(I=a*Math.pow(1-h/r,o)),0!==I){let t=I*s;Math.abs(t)>=1&&(e.scrollTop+=Math.round(t))}}),()=>{null!==d.current&&cancelAnimationFrame(d.current),d.current=null,c.current=0,null!=e&&(e.style.overflowAnchor="auto",e.style.overscrollBehavior="auto")}},[t,f,h?.itemType,i,r,a,o,I])}}