https://github.com/hanford/react-scroll-listen
efficiently save the scroll position of the document.body in React
https://github.com/hanford/react-scroll-listen
event listener react scroll
Last synced: 4 months ago
JSON representation
efficiently save the scroll position of the document.body in React
- Host: GitHub
- URL: https://github.com/hanford/react-scroll-listen
- Owner: hanford
- Created: 2017-07-26T05:11:12.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-09-11T19:06:59.000Z (over 7 years ago)
- Last Synced: 2024-12-01T16:47:14.397Z (5 months ago)
- Topics: event, listener, react, scroll
- Language: JavaScript
- Size: 13.7 KB
- Stars: 6
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## react-scroll-listen
Save the value of the document scroll position efficiently with one event listener
## Install
```
$ npm install react-scroll-listen --save
```## Usage
```js
import ScrollListener from 'react-scroll-listen'render () {
return (
this.setState({scrollPosition: value})}
/>
)
}
```## API / Props
| Param | Type | args | default | required |
|--------------------|---------|--------------|---------------|----------|
| onScroll | Function| value, event | | true |
| container | ref | | window | false |
| element | ref | | document.body | false |Note: `containerToListenOn` and `containerToScroll` can be the same but don't have to be
MIT © [Jack Hanford](http://jackhanford.com)