mirror of
https://github.com/vichan-devel/vichan.git
synced 2024-12-18 02:16:03 +01:00
auto-reload.js: tweak timeouts, so now it gets new posts even if not at bottom
This commit is contained in:
parent
6620c10b7b
commit
42ae3550f9
@ -21,6 +21,8 @@ $(document).ready(function(){
|
|||||||
return; //not thread page
|
return; //not thread page
|
||||||
|
|
||||||
var poll_interval;
|
var poll_interval;
|
||||||
|
|
||||||
|
var end_of_page = false;
|
||||||
|
|
||||||
var poll = function() {
|
var poll = function() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@ -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() {
|
$(window).scroll(function() {
|
||||||
if($(this).scrollTop() + $(this).height() < $('div.post:last').position().top + $('div.post:last').height()) {
|
if($(this).scrollTop() + $(this).height() < $('div.post:last').position().top + $('div.post:last').height()) {
|
||||||
clearTimeout(poll_interval);
|
end_of_page = false;
|
||||||
poll_interval = false;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(poll_interval === false) {
|
clearTimeout(poll_interval);
|
||||||
poll_interval = setTimeout(poll, 1500);
|
poll_interval = setTimeout(poll, 100);
|
||||||
}
|
end_of_page = true;
|
||||||
}).trigger('scroll');
|
}).trigger('scroll');
|
||||||
|
|
||||||
|
poll_interval = setTimeout(poll, 3000);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user