Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/bonnevoyager/react-scroll-position

Remember and restore React scroll position for html element nodes.
https://github.com/bonnevoyager/react-scroll-position

react scroll scroll-position

Last synced: 5 days ago
JSON representation

Remember and restore React scroll position for html element nodes.

Awesome Lists containing this project

README

        

# react-scroll-position

ScrollPosition HOC which remembers attached node scroll position and restores it.

## Installation

```
npm install --save react-scroll-position
```

## Usage

```js
import React, { Component} from 'react'
import ScrollPosition from 'react-scroll-position'

const RememberMyScroll = ({ children }) => (

{
({ attachScrollNode, getScroll, getScrollNode, setScroll }) =>


{children}

}

)
```

ScrollPosition HOC uses children as function and returns functions which can be used to manipulate the scrolling.

#### attachScrollNode

Expects HTMLElement `node`.

#### getScroll

Gets attached `node` x and y scroll positions.

#### getScrollNode

Gets attached HTMLElement `node`.

#### setScroll

Sets attached `node` x and y scroll positions.

## License

[MIT](LICENSE)