I've been working on creating an ajax request that triggers when a div is scrolled to the bottom. I thought I had it figured out with this code, but I've run into an issue. Everything works fine without subtracting 100 from the elem.outerHeight() inside the if statement. However, I really want to load the extra images before it reaches the very end, so I tried subtracting 100 pixels. Unfortunately, it just won't cooperate. Here's the code with the subtraction:
$('#thubnails').scroll(chk_scroll);
function chk_scroll(e) {
var elem = $(e.currentTarget);
if (elem[0].scrollHeight - elem.scrollTop() == elem.outerHeight()-100) {
loadmoreimg();
console.log(elem.outerHeight());
}
}
Anyone have a solution to this problem?