using the following will execute action even if the user crolls from the end to the start. I want just when the user scrolls down vertically
if( $(window).scrollTop() + $(window).height() == $(document).height() ) {
//do stuff
}
this is my code so far,
function addEvent( obj, type, fn ) {
if ( obj.attachEvent ) {
obj['e'+type+fn] = fn;
obj[type+fn] = function(){obj['e'+type+fn]( window.event );}
obj.attachEvent( 'on'+type, obj[type+fn] );
} else
obj.addEventListener( type, fn, false );
}
addEvent(window, 'scroll', function(event) {
if( $(window).scrollTop() + $(window).height() == $(document).height() ) {
load();
}
});