0

我为我的网站使用 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);
  }
};

提前致谢。我环顾四周并尝试了一些不同的东西,但没有运气。干杯。

4

1 回答 1

5

我刚刚在 GitHub 存储库中添加了一个关于如何执行此操作的示例。该示例从 Wookmark API 加载数据并在页面上显示图像。当您向下滚动并到达底部时,它会加载更多。

这是示例的直接链接:https ://github.com/GBKS/Wookmark-jQuery/tree/master/example-api

让我知道这对你有什么影响。

于 2012-04-27T13:29:25.363 回答