sambernard / react-waypoint

A React component to execute a function whenever you scroll to an element.

Home Page:http://brigade.github.io/react-waypoint/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

React Waypoint

npm version bower version Build Status

A React component to execute a function whenever you scroll to an element. Works in all containers that can scroll, including the window.

React Waypoint can be used to build features like lazy loading content, infinite scroll, or docking elements to the viewport on scroll.

Inspired by Waypoints, except this little library grooves the React way.

Demo

Demo of React Waypoint in action

View demo page

Installation

npm

npm install react-waypoint --save

Bower

bower install react-waypoint --save

Usage

var Waypoint = require('react-waypoint');
<Waypoint
  onEnter={this._handleWaypointEnter}
  onLeave={this._handleWaypointLeave}
  threshold={0.2}
/>

###Example: JSFiddle Example

Prop types

  propTypes: {
    onEnter: PropTypes.func, // function called when waypoint enters viewport
    onLeave: PropTypes.func, // function called when waypoint leaves viewport
    threshold: PropTypes.number, // threshold is percentage of the height of
    // the visible part of the scrollable parent (e.g. 0.1)
  },

Credits

Credit to trotzig and lencioni for writing this component, and the Brigade team for open sourcing it.

Thanks to the creator of the original Waypoints library, imakewebthings.

License

MIT

About

A React component to execute a function whenever you scroll to an element.

http://brigade.github.io/react-waypoint/

License:MIT License


Languages

Language:JavaScript 100.0%