szurubooru/public_html/media/js/paginator-endless.js

32 lines
820 B
JavaScript
Raw Normal View History

2013-10-09 12:18:22 +02:00
function scrolled()
{
var margin = 150;
if ($(document).height() <= $(window).scrollTop() + $(window).height() + margin)
{
var pageNext = $(document).data('page-next');
var pageDone = $(document).data('page-done');
if (pageNext == null)
{
pageNext = $('.paginator .next:not(.inactive) a').attr('href');
}
if (pageNext != null && pageNext != pageDone)
{
$(document).data('page-done', pageNext);
$.get(pageNext, [], function(response)
{
var dom = $(response);
var nextPage = dom.find('.paginator .next:not(.inactive) a').attr('href');
$(document).data('page-next', nextPage);
2013-10-10 00:12:27 +02:00
$('.paginator-content').append($(response).find('.paginator-content').children().fadeIn('slow'));
2013-10-09 12:18:22 +02:00
});
}
}
}
$(function()
{
$('.paginator').hide();
$(window).scroll(scrolled);
scrolled();
});