javascript - Horizontal AJAX posts loader, detect when scrollbar reaches the end -


i've set div (#reviewspostscont) overflow-x:scroll, want load posts ajax cant't detect when scrollbar gets right end. down below code have far, can't understand whats wrong it. in advance, matt

   $('#reviewspostscont').scroll(function(){    var $this = $(this);    scrollpercentage = 100 * $(this).scrollleft() / ($('#reviewspostscont').width() - $(this).width());                  if  (scrollpercentage == 100){                     alert('end!');  // test code, ajax                 }         });  

the issue around how calculate total scroll width. have added jsfiddle. basically, instead of:

scrollpercentage = 100 * $(this).scrollleft() /      ($('#reviewspostscont').width() - $(this).width()); 

you should have:

scrollpercentage = 100 * $(this).scrollleft() /     ($(this)[0].scrollwidth - $(this).width()); 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -