Skip to content

efficiently save the scroll position of the document.body in React

Notifications You must be signed in to change notification settings

hanford/react-scroll-listen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-scroll-listen

Save the value of the document scroll position efficiently with one event listener


Install

$ npm install react-scroll-listen --save

Usage

import ScrollListener from 'react-scroll-listen'

render () {
  return (
    <ScrollListener
      onScroll={value => 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

About

efficiently save the scroll position of the document.body in React

Topics

Resources

Stars

Watchers

Forks

Packages