UNPKG

@thibault.sh/hooks

Version:

A comprehensive collection of React hooks for browser storage, UI interactions, and more

2 lines 507 B
'use strict';var react=require('react');function t(){let[n,e]=react.useState({x:typeof window!="undefined"?window.scrollX:0,y:typeof window!="undefined"?window.scrollY:0});return react.useEffect(()=>{if(typeof window=="undefined")return;let o=()=>{e({x:window.scrollX,y:window.scrollY});};return window.addEventListener("scroll",o),o(),()=>window.removeEventListener("scroll",o)},[]),n}exports.useScrollPosition=t;//# sourceMappingURL=useScrollPosition.cjs.map //# sourceMappingURL=useScrollPosition.cjs.map