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?
This is possible to do with Waypoints by setting the context option to the scrollable element.
<div id="overflow-scroll">
<div id="context-example">I am a waypoint with a custom context, the "#overflow-scroll" div.</div>
</div>
<script>
var waypoint = new Waypoint({
element: document.getElementById('context-example'),
handler: function() {
console.log('Context example triggered')
},
context: document.getElementById('overflow-scroll')
})
</script>