useScroll()
npm i @react-hooks-custom/use-scroll
A React hook for updating components when the scroll position of the window on the y-axis changes.
Quick Start
import useScroll from '@react-hooks-custom/use-scroll'
const Component = (props) => {
const { scrollX, scrollY } = useScroll();
return <div>scroll pos: {scrollX}, {scrollY}</div>
}
API
useScroll () => ScrollType
type ScrollType = {
scrollX: number;
scrollY: number;
}
Returns { scrollX, scrollY }
Type | Description | |
---|---|---|
scrollX | number | The current scroll position of the window on the x-axis |
scrollY | number | The current scroll position of the window on the y-axis |
LICENSE
MIT