1.0.1 • Published 6 years ago

react-scroll-captor v1.0.1

Weekly downloads
205
License
MIT
Repository
github
Last release
6 years ago

React Scroll Captor

A component that confines scroll events to its immediate child. Great for dropdown menus etc.

Install

yarn add react-scroll-captor

Use

import ScrollCaptor from 'react-scroll-captor';

class GroovyThing extends Component {
  atBottom = () => {
    // user has scrolled to the bottom
  }
  render () {
    return (
      <ScrollCaptor onBottomArrive={this.atBottom}>
        <ScrollableElement />
      </ScrollCaptor>
    );
  }
}

Props

PropertyTypeDefaultDescription
isEnabledbooleantrueEnable or disable the component.
onBottomArrivefunction--Called when the user reaches the bottom of the scrollable element.
onBottomLeavefunction--Called when the user leaves the bottom of the scrollable element.
onTopArrivefunction--Called when the user reaches the top of the scrollable element.
onTopLeavefunction--Called when the user leaves the top of the scrollable element.