I'm trying to implement an infinite scroll on my site, like this one , but I'm having difficulty do the script that takes the mouse scroll event. I tried to use this script (below) I got on a website, but it's not exactly what I need. Anyone have any suggestions?
cont=0
function handle(delta) {
var nav = document.getElementById('navegacao');
var ln = nav.getElementsByTagName('a');
if (delta < 0){
cont=cont+1;
ln[cont].click();
}
else{
cont=cont-1;
ln[cont].click();
}
}
function wheel(event){
var delta = 0;
if (!event) event = window.event;
if (event.wheelDelta) {
delta = event.wheelDelta/120;
} else if (event.detail) {
delta = -event.detail/3;
}
if (delta)
handle(delta);
if (event.preventDefault)
event.preventDefault();
event.returnValue = false;
}
/* Initialization code. */
if (window.addEventListener)
window.addEventListener('DOMMouseScroll', wheel, false);
window.onmousewheel = document.onmousewheel = wheel;