Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rehooks/window-scroll-position
React hook for Window scroll position
https://github.com/rehooks/window-scroll-position
hook react react-hooks scroll window
Last synced: about 2 months ago
JSON representation
React hook for Window scroll position
- Host: GitHub
- URL: https://github.com/rehooks/window-scroll-position
- Owner: rehooks
- License: mit
- Created: 2018-10-25T21:40:48.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2021-09-01T02:37:59.000Z (over 3 years ago)
- Last Synced: 2024-10-03T06:57:38.740Z (2 months ago)
- Topics: hook, react, react-hooks, scroll, window
- Language: JavaScript
- Homepage:
- Size: 768 KB
- Stars: 82
- Watchers: 3
- Forks: 13
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- fucking-awesome-react-hooks - `@rehooks/window-scroll-position`
- awesome-react-hooks-cn - `@rehooks/window-scroll-position`
- awesome-react-hooks - `@rehooks/window-scroll-position`
- awesome-react-hooks - `@rehooks/window-scroll-position`
README
# `@rehooks/window-scroll-position`
> React hook for [Window](https://developer.mozilla.org/en-US/docs/Web/API/Window) scroll position
> **Note:** This is using the new [React Hooks API Proposal](https://reactjs.org/docs/hooks-intro.html)
> which is subject to change until React 16.7 final.
>
> You'll need to install `react`, `react-dom`, etc at `^16.7.0-alpha.0`## Install
```sh
yarn add @rehooks/window-scroll-position
```## Usage
```js
import useWindowScrollPosition from '@rehooks/window-scroll-position'function MyComponent() {
// optionally you can pass options, those are default:
let options = {
throttle: 100,
}
let position = useWindowScrollPosition(options)
// position == { x: 0, y: 0 }
return
}
```