我将Paul Irish的Infinite-Scroll jQuery plugin与Isotope结合使用。它似乎运作良好,除了一件事:加载动画根本没有出现。此外,当您向下滚动时,原始分页链接会在一秒钟内显示,然后它们会消失,大约一秒钟后会显示下一个页面'负载。因为第二页'页需要一秒钟。加载,我真的希望加载动画出现,以便用户知道正在加载另一个页面。如何强制分页链接不可见并显示加载动画?以下是我使用的代码:
// Isotope (with Infinite Scroll)
$(function(){
var $container = $('.isotope-container');
$container.imagesLoaded(function(){
$container.masonry({
itemSelector: '.isotope-item',
layoutMode: 'masonry'
});
});
// filter items on button click
$('#filters').on( 'click', 'button', function() {
var selector = $(this).attr('data-filter');
$container.isotope({ filter: selector });
});
$container.infinitescroll({
navSelector : '.pagination', // selector for the paged navigation
nextSelector : '.next-post a', // selector for the NEXT link (to page 2)
itemSelector : '.isotope-item', // selector for all items you'll retrieve
loading: {
finishedMsg: 'No more pages to load.',
msgText: "loading new posts",
img: 'http://i.imgur.com/6RMhx.gif',
selector: "#loading-animation"
}
},
// trigger Masonry as a callback
function( newElements ) {
// hide new items while they are loading
var $newElems = $( newElements ).css({ opacity: 0 });
// ensure that images load before adding to masonry layout
$newElems.imagesLoaded(function(){
// show elems now they're ready
$newElems.animate({ opacity: 1 });
$container.masonry( 'appended', $newElems, true );
});
}
);
});
编辑:在检查页面时,看起来加载div #infscr-loading
正在其他元素下方的页面顶部加载。但我无法弄清楚如何让它在底部加载...
答案 0 :(得分:0)
我在这篇文章的帮助下找到了这个解决方案:http://wpquestions.com/question/show/id/8043。
#infscr-loading {
position: fixed;
bottom: 30px;
left: 42%;
z-index: 100;
background: white;
background: hsla( 0, 0%, 100%, 0.9 );
padding: 20px;
color: #222;
font-size: 15px;
font-weight: bold;
}