@react-hooks-custom/use-scroll

1.1.1 • Public • Published

useScroll()

Bundlephobia Types NPM Version

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

Package Sidebar

Install

npm i @react-hooks-custom/use-scroll

Weekly Downloads

12

Version

1.1.1

License

MIT

Unpacked Size

6.08 kB

Total Files

7

Last publish

Collaborators

  • littleee