Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/bonnevoyager/react-scroll-position
- Owner: BonneVoyager
- Created: 2020-01-14T18:49:38.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-07-11T03:15:41.000Z (over 1 year ago)
- Last Synced: 2024-11-01T03:42:38.055Z (14 days ago)
- Topics: react, scroll, scroll-position
- Language: JavaScript
- Homepage:
- Size: 374 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
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)