我使用我的网站的Wookmark jQuery网格布局。
https://github.com/GBKS/Wookmark-jQuery
我需要自动加载/无休止的滚动工作。
在示例中,它只是再次加载前 10 张图像,如何让它继续加载列表的其余部分,就像在 Wookmark.com 和 Pinterest.com 上一样?
我一直试图更改的代码部分:
/**
* When scrolled all the way to the bottom, add more tiles.
*/
function onScroll(event) {
// Check if we're within 100 pixels of the bottom edge of the broser window.
var closeToBottom = ($(window).scrollTop() + $(window).height() > $(document).height() - 100);
if(closeToBottom) {
// Get the first then items from the grid, clone them, and add them to the bottom of the grid.
var items = $('#tiles li');
var firstTen = items.slice(0, 10);
$('#tiles').append(firstTen.clone());
// Clear our previous layout handler.
if(handler) handler.wookmarkClear();
// Create a new layout handler.
handler = $('#tiles li');
handler.wookmark(options);
}
};
提前谢谢。我到处环顾四周,尝试了一些不同的东西,但没有运气。干杯。
我刚刚在 GitHub 存储库中添加了一个示例,说明如何做到这一点。该示例从 Wookmark API 加载数据并在页面上显示图像。当您向下滚动并到达底部时,它会加载更多。
下面是示例的直接链接:https://github.com/GBKS/Wookmark-jQuery/tree/master/example-api
让我知道这对您来说是如何工作的。