An open API service indexing awesome lists of open source software.

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

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)