Build 576754stable
Module 600761
1,439 characters · in ad3fccc0e5cfe756.js, a9a0b04623ac0dcd.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:u=2.2}=e,c=(0,n.useRef)(null),o=(0,n.useRef)(0),d=(0,n.useRef)({top:0,bottom:0}),g=(0,n.useRef)(null),f=(0,n.useCallback)(e=>({isDragging:e.isDragging(),clientOffset:e.getClientOffset(),item:e.getItem()}),[]),{isDragging:m,clientOffset:I,item:x}=(0,s.V)(f);(0,n.useEffect)(()=>{g.current=I},[I]);let E=(0,l.VU)();(0,n.useEffect)(()=>{let e=t.current;if(null==e)return;if(!(!0===m&&x?.itemType===i&&!E)){null!==c.current&&cancelAnimationFrame(c.current),c.current=null,e.style.overflowAnchor="auto",e.style.overscrollBehavior="auto",o.current=0;return}let n=e.getBoundingClientRect();return d.current={top:n.top,bottom:n.bottom},e.style.overflowAnchor="none",e.style.overscrollBehavior="contain",c.current=requestAnimationFrame(function t(i){c.current=requestAnimationFrame(t);let n=g.current;if(null==e||null==n){o.current=i;return}let s=Math.min(32,0!==o.current?i-o.current:16)/1e3;o.current=i;let{top:l,bottom:f}=d.current,m=n.y,I=m-l,x=f-m,E=0;if(I>=0&&I<r?E=-a*Math.pow(1-I/r,u):x>=0&&x<r&&(E=a*Math.pow(1-x/r,u)),0!==E){let t=E*s;Math.abs(t)>=1&&(e.scrollTop+=Math.round(t))}}),()=>{null!==c.current&&cancelAnimationFrame(c.current),c.current=null,o.current=0,null!=e&&(e.style.overflowAnchor="auto",e.style.overscrollBehavior="auto")}},[t,m,x?.itemType,i,r,a,u,E])}}