@thibault.sh/hooks
Version:
A comprehensive collection of React hooks for browser storage, UI interactions, and more
2 lines • 800 B
JavaScript
import {b,a}from'./chunk-IJZYV2FY.mjs';import {useState,useEffect}from'react';function H(e,s=150){let[u,o]=useState({scrollTop:0,scrollLeft:0,scrollWidth:0,scrollHeight:0,clientWidth:0,clientHeight:0,isScrolling:!1});return useEffect(()=>{if(!e.current)return;let l,t=e.current,r=()=>{let{scrollTop:m,scrollLeft:h,scrollWidth:f,scrollHeight:a$1,clientWidth:S,clientHeight:b$1}=t;o(c=>({scrollTop:m,scrollLeft:h,scrollWidth:f,scrollHeight:a$1,clientWidth:S,clientHeight:b$1,isScrolling:!0})),clearTimeout(l),l=setTimeout(()=>{o(c=>b(a({},c),{isScrolling:!1}));},s);};return t.addEventListener("scroll",r),r(),()=>{t.removeEventListener("scroll",r),clearTimeout(l);}},[e]),u}export{H as useContainerScroll};//# sourceMappingURL=useContainerScroll.mjs.map
//# sourceMappingURL=useContainerScroll.mjs.map