Waypoints is the easiest way to trigger a function when you scroll to an element.

var waypoint = new Waypoint({
  element: document.getElementById('waypoint'),
  handler: function(direction) {
    console.log('Scrolled to waypoint!')
  }
})

Builds are available for multiple DOM libraries.

  • jQuery 1.8+
  • Zepto 1.1+
  • No Framework IE 9+
npm install waypoints

or

bower install waypoints

or