UNPKG

@byteclaw/use-overflow-scroll-position

Version:

React hook for calculating number of pixels scrolled through in an overflow:scroll enabled container

3 lines (2 loc) 554 B
var e=require("react");exports.useOverflowScrollPosition=function(r){var n=e.useState([null,null]),t=n[0],u=n[1],c=e.useCallback(function(){null!=r.current&&u([r.current.scrollTop+r.current.clientHeight,r.current.scrollHeight])},[r]);return e.useLayoutEffect(function(){if(null!=r.current)return c(),window.addEventListener("resize",c),r.current.addEventListener("scroll",c),function(){window.removeEventListener("resize",c),r.current&&r.current.removeEventListener("scroll",c)}},[r.current]),t}; //# sourceMappingURL=use-overflow-scroll-position.js.map