ScrollPosition HOC which remembers attached node scroll position and restores it.
npm install --save react-scroll-position
import React, { Component} from 'react'
import ScrollPosition from 'react-scroll-position'
const RememberMyScroll = ({ children }) => (
<ScrollPosition scrollKey="my-scroll">
{
({ attachScrollNode, getScroll, getScrollNode, setScroll }) =>
<div ref={attachScrollNode}>
{children}
</div>
}
</ScrollPosition>
)
ScrollPosition HOC uses children as function and returns functions which can be used to manipulate the scrolling.
Expects HTMLElement node
.
Gets attached node
x and y scroll positions.
Gets attached HTMLElement node
.
Sets attached node
x and y scroll positions.