Skip to content
Advertisement

Javascript Waypoints (or alternative)

I tryied to use the Waypoints library to fire an event when we scroll to the end of a div (in order to implement an “infinite scolling”-like functionality). I looked at this example but it apparently doesn’t work if I use a custom scrollable ‘div’, it only works for the window scrolling. Here my fiddle: http://jsfiddle.net/qa68m10n/6/

 var waypoint = new Waypoint({
  element: document.getElementById('waypoint'),
  handler: function(direction) {
    console.log('waypoint')
  },
  offset: 'bottom-in-view' 
})

Am I right? Is there an alternative?

Answer

This is possible to do with Waypoints by setting the context option to the scrollable element. http://imakewebthings.com/waypoints/api/context-option/

Advertisement