@react-hooks-custom/use-scroll
v1.1.1
Published
Get scrolling value quickly by React hook
Downloads
42
Maintainers
Readme
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