无限滚动加载太快

发布于 2024-12-23 09:17:06 字数 971 浏览 1 评论 0原文

这里有很多单独的问题,我想弄清楚,所以对最近的很多帖子表示歉意;)

我的网站上有无限滚动(其他问题我们不会提及),但整个事情似乎启动得太快,尤其是在分页存在。

这就是我所拥有的:

<script src="<?php bloginfo('template_directory'); ?>/js/jquery.infinitescroll.min.js"></script>
<script>
  $(function(){

var $container = $('.rest-of-content');

  $container.infinitescroll({
    navSelector  : '.wp-paginate',    // selector for the paged navigation 
    nextSelector : '.wp-paginate li a',  // selector for the NEXT link (to page 2)
    itemSelector : '.single-fg-post',     // selector for all items you'll retrieve
    bufferPX: 20,
    loading: {
      msgText: 'Fetching more gold...',
      finishedMsg: 'Damn! No more gold!',
      img: '<?php bloginfo('template_directory'); ?>/images/ajax-loader-black.gif'
    }
});

  });
</script>

但是,如果您看看它的工作方式: http://goo.gl/L9p00 - 如果你向下滚动一点,你可以看到滚动条滑块变短,因为它在我到达之前就加载了内容。

Lots of separate issues here that I want to figure out so apologies for lots of recent posts ;)

I have infinite scroll working on my site (other issues we won't mention) yet the whole thing seems to fire too quickly, especially before the pagination exists.

This is what I have:

<script src="<?php bloginfo('template_directory'); ?>/js/jquery.infinitescroll.min.js"></script>
<script>
  $(function(){

var $container = $('.rest-of-content');

  $container.infinitescroll({
    navSelector  : '.wp-paginate',    // selector for the paged navigation 
    nextSelector : '.wp-paginate li a',  // selector for the NEXT link (to page 2)
    itemSelector : '.single-fg-post',     // selector for all items you'll retrieve
    bufferPX: 20,
    loading: {
      msgText: 'Fetching more gold...',
      finishedMsg: 'Damn! No more gold!',
      img: '<?php bloginfo('template_directory'); ?>/images/ajax-loader-black.gif'
    }
});

  });
</script>

Yet, if you look at the way it works: http://goo.gl/L9p00 - if you scroll down a little, you can see the scrollbar slider shorten as it loads the content before I have even reached it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

水水月牙 2024-12-30 09:17:06

这并没有什么问题。它完全按照预期工作。您希望页面在到达底部之前呈现,因为您不希望用户必须等待。您的服务器可以承受打击。您的用户无法忍受等待。

查看 Pinterest 即可看到完全相同的操作。

There is nothing wrong with this. It's working exactly as intended. You want the page to render before hitting the bottom because you don't want the user to have to wait. Your servers can take the hit. Your users can't stand the wait.

Take a look at Pinterest to see the exact same thing in action.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文