UNPKG

scrollbun

Version:

React component for horizontal scrolling

2 lines (1 loc) 610 B
function H({children:p,style:q,direction:b="horizontal",scrollRate:w=0.5,...z}){const A={vertical:{overflowY:"scroll"},horizontal:{overflowX:"scroll",display:"flex"}};function C(k){return(P)=>{if(b==="vertical")return;const B=P.currentTarget,D=B.getBoundingClientRect().width,F=B.scrollLeft===0,G=B.scrollLeft===B.scrollWidth-D;if(!F&&!G)P.preventDefault(),P.stopPropagation();B.scrollLeft+=P.deltaY*k,B.scrollLeft+=P.deltaX*k}}return I("div",{onWheel:C(w),style:{...q,...A[b]},...z,children:p},void 0,!1,void 0,this)}import{jsxDEV as I} from"react/jsx-dev-runtime";var K=H;export{K as default,H as Scroller};