mirror of
https://github.com/vichan-devel/vichan.git
synced 2024-11-12 01:50:48 +01:00
ukko: further fixes; should now provide a smooth overboard experience
This commit is contained in:
parent
7ed01737c7
commit
e2b5ec9354
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
var cache = new Array(),
|
var cache = new Array(),
|
||||||
thread = false,
|
thread = false,
|
||||||
loading = false;
|
loading = false,
|
||||||
|
ukkotimer = false;
|
||||||
if (localStorage.hiddenboards !== null) {
|
if (localStorage.hiddenboards !== null) {
|
||||||
localStorage.hiddenboards = "{}";
|
localStorage.hiddenboards = "{}";
|
||||||
}
|
}
|
||||||
@ -52,11 +52,11 @@ $(document).ready(function() {
|
|||||||
$("h2").each(addukkohide);
|
$("h2").each(addukkohide);
|
||||||
|
|
||||||
$('.pages').hide();
|
$('.pages').hide();
|
||||||
$(window).on('scroll', function() {
|
var loadnext = function() {
|
||||||
if (overflow.length == 0) {
|
if (overflow.length == 0) {
|
||||||
$('.pages').show().html(_("No more threads to display"));
|
$('.pages').show().html(_("No more threads to display"));
|
||||||
}
|
}
|
||||||
while($(window).scrollTop() + $(window).height() + 500 > $(document).height() && !loading && overflow.length > 0) {
|
while($(window).scrollTop() + $(window).height() + 1000 > $(document).height() && !loading && overflow.length > 0) {
|
||||||
var page = '../' + overflow[0].board + '/' + overflow[0].page;
|
var page = '../' + overflow[0].board + '/' + overflow[0].page;
|
||||||
thread = $('div#thread_' + overflow[0].id + '[data-board="' + overflow[0].board + '"]');
|
thread = $('div#thread_' + overflow[0].id + '[data-board="' + overflow[0].board + '"]');
|
||||||
if (thread.length > 0 && thread.attr("data-cached") !== 'yes') { // already present
|
if (thread.length > 0 && thread.attr("data-cached") !== 'yes') { // already present
|
||||||
@ -66,11 +66,13 @@ $(document).ready(function() {
|
|||||||
|
|
||||||
var boardheader = $('<h2><a href="/' + overflow[0].board + '/">/' + overflow[0].board + '/</a> </h2>');
|
var boardheader = $('<h2><a href="/' + overflow[0].board + '/">/' + overflow[0].board + '/</a> </h2>');
|
||||||
|
|
||||||
if($.inArray(page, cache) != -1 && thread.length > 0) {
|
if($.inArray(page, cache) != -1) {
|
||||||
|
if (thread.length > 0) {
|
||||||
$('div[id*="thread_"]').last().after(thread.attr('data-board', overflow[0].board).attr("data-cached", "no").css('display', 'block'));
|
$('div[id*="thread_"]').last().after(thread.attr('data-board', overflow[0].board).attr("data-cached", "no").css('display', 'block'));
|
||||||
boardheader.insertBefore(thread);
|
boardheader.insertBefore(thread);
|
||||||
addukkohide.call(boardheader);
|
addukkohide.call(boardheader);
|
||||||
$(document).trigger('new_post', thread);
|
$(document).trigger('new_post', thread);
|
||||||
|
}
|
||||||
overflow.shift();
|
overflow.shift();
|
||||||
} else {
|
} else {
|
||||||
loading = true;
|
loading = true;
|
||||||
@ -92,11 +94,8 @@ $(document).ready(function() {
|
|||||||
boardheader.insertBefore(thread);
|
boardheader.insertBefore(thread);
|
||||||
addukkohide.call(boardheader);
|
addukkohide.call(boardheader);
|
||||||
$(document).trigger('new_post', thread);
|
$(document).trigger('new_post', thread);
|
||||||
|
}
|
||||||
overflow.shift();
|
overflow.shift();
|
||||||
}
|
|
||||||
else {
|
|
||||||
overflow.shift(); // We missed it? Or already present...
|
|
||||||
}
|
|
||||||
|
|
||||||
loading = false;
|
loading = false;
|
||||||
$('.pages').hide().html("");
|
$('.pages').hide().html("");
|
||||||
@ -104,7 +103,13 @@ $(document).ready(function() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
clearTimeout(ukkotimer);
|
||||||
|
ukkotimer = setTimeout(loadnext, 1000);
|
||||||
|
};
|
||||||
|
|
||||||
|
$(window).on('scroll', loadnext);
|
||||||
|
|
||||||
|
ukkotimer = setTimeout(loadnext, 1000);
|
||||||
});
|
});
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
Loading…
Reference in New Issue
Block a user