在我正在构建https://vase.ai/blog/的此网站中,我使用无限滚动脚本将多个页面制作为一个页面进行滚动。如何在没有更多页面加载时隐藏加载程序
我想隐藏加载器(旋转的),当没有更多的页面加载。我盘算了一下,下面的代码也许能够帮我检测错误(Failed to load resource: the server responded with a status of 404 (Not Found))
并执行躲藏。但是,这是行不通的。我失去了一些东西,我用它来加载?
window.addEventListener('error', function(e) {
$('loading').fadeOut()
}, true);
代码更多:
//implementing infinite scrolling
$grid.infinitescroll({
// Pagination element that will be hidden
navSelector: '.pagination',
// Next page link
nextSelector: '.pagination a',
// Selector of items to retrieve
itemSelector: '.grid-blog',
},
// Function called once the elements are retrieved
function(new_elts) {
var elts = $(new_elts).css('opacity', 0);
elts.animate({opacity: 1});
$grid.packery('appended', elts);
$('.target-resize').textfill({
maxFontPixels: 36,
changeLineHeight:false
})
$grid.packery({
itemSelector: '.grid-blog',
gutter: 20,
})
});
你可以包括您所使用加载额外页面的代码? – Remi
@TheRickest你更新了代码。 – tnkh