UNPKG

@thibault.sh/hooks

Version:

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

2 lines 497 B
import {useState,useEffect}from'react';function t(){let[n,e]=useState({x:typeof window!="undefined"?window.scrollX:0,y:typeof window!="undefined"?window.scrollY:0});return 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}export{t as useScrollPosition};//# sourceMappingURL=useScrollPosition.mjs.map //# sourceMappingURL=useScrollPosition.mjs.map