auto-reload.js: tweak timeouts, so now it gets new posts even if not at bottom
This commit is contained in:
parent
f8f0da92d4
commit
5817194be4
@ -22,6 +22,8 @@ $(document).ready(function(){
|
||||
|
||||
var poll_interval;
|
||||
|
||||
var end_of_page = false;
|
||||
|
||||
var poll = function() {
|
||||
$.ajax({
|
||||
url: document.location,
|
||||
@ -36,19 +38,21 @@ $(document).ready(function(){
|
||||
}
|
||||
});
|
||||
|
||||
poll_interval = setTimeout(poll, 5000);
|
||||
clearTimeout(poll_interval);
|
||||
poll_interval = setTimeout(poll, end_of_page ? 3000 : 10000);
|
||||
};
|
||||
|
||||
$(window).scroll(function() {
|
||||
if($(this).scrollTop() + $(this).height() < $('div.post:last').position().top + $('div.post:last').height()) {
|
||||
clearTimeout(poll_interval);
|
||||
poll_interval = false;
|
||||
end_of_page = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if(poll_interval === false) {
|
||||
poll_interval = setTimeout(poll, 1500);
|
||||
}
|
||||
clearTimeout(poll_interval);
|
||||
poll_interval = setTimeout(poll, 100);
|
||||
end_of_page = true;
|
||||
}).trigger('scroll');
|
||||
|
||||
poll_interval = setTimeout(poll, 3000);
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user