mirror of
https://github.com/vichan-devel/vichan.git
synced 2024-11-24 23:50:11 +01:00
Attempted performance fix for scroll in auto-reload
This commit is contained in:
parent
2a40d82c00
commit
adf086de6e
@ -17,6 +17,17 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// From http://stackoverflow.com/a/14035162
|
||||||
|
$.fn.scrollStopped = function(callback) {
|
||||||
|
$(this).scroll(function(){
|
||||||
|
var self = this, $this = $(self);
|
||||||
|
if ($this.data('scrollTimeout')) {
|
||||||
|
clearTimeout($this.data('scrollTimeout'));
|
||||||
|
}
|
||||||
|
$this.data('scrollTimeout', setTimeout(callback,250,self));
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
function makeIcon(mode){
|
function makeIcon(mode){
|
||||||
var favicon = $("link[rel='shortcut icon']");
|
var favicon = $("link[rel='shortcut icon']");
|
||||||
|
|
||||||
@ -168,10 +179,11 @@ $(document).ready(function(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var recheck_activated = function() {
|
var recheck_activated = function(end_of_page) {
|
||||||
if (new_posts && window_active &&
|
if (typeof end_of_page == "undefined") var end_of_page = false;
|
||||||
|
if (end_of_page || (new_posts && window_active &&
|
||||||
$(window).scrollTop() + $(window).height() >=
|
$(window).scrollTop() + $(window).height() >=
|
||||||
$('div.boardlist.bottom').position().top) {
|
$('div.boardlist.bottom').position().top)) {
|
||||||
|
|
||||||
new_posts = 0;
|
new_posts = 0;
|
||||||
}
|
}
|
||||||
@ -286,18 +298,18 @@ $(document).ready(function(){
|
|||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
$(window).scroll(function() {
|
$(window).scrollStopped(function() {
|
||||||
// if the newest post is not visible
|
// if the newest post is not visible
|
||||||
if($(this).scrollTop() + $(this).height() <
|
if($(this).scrollTop() + $(this).height() <
|
||||||
$('div.post:last').position().top + $('div.post:last').height()) {
|
$('div.post:last').position().top + $('div.post:last').height()) {
|
||||||
end_of_page = false;
|
end_of_page = false;
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
if($("#auto_update_status").is(':checked') && timeDiff(poll_interval_mindelay)) {
|
if($("#auto_update_status").is(':checked') && timeDiff(poll_interval_mindelay)) {
|
||||||
poll(manualUpdate = true);
|
poll(manualUpdate = true);
|
||||||
}
|
}
|
||||||
end_of_page = true;
|
end_of_page = true;
|
||||||
}
|
}
|
||||||
|
recheck_activated(end_of_page);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#update_thread').on('click', function() { poll(manualUpdate = true); return false; });
|
$('#update_thread').on('click', function() { poll(manualUpdate = true); return false; });
|
||||||
|
Loading…
Reference in New Issue
Block a user