在用户向下滚动时加载内容 [英] Loading content as the user scrolls down

查看:22
本文介绍了在用户向下滚动时加载内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个博客类型的页面,我想在用户向下滚动时将项目加载到页面中,就像 Google 阅读器或 Soup.io.您将如何实现这种效果?我看过一些读取页面高度的示例,并且甚至将 onScroll 附加到窗口,以便当用户向下滚动时,我们可以测试他们是否向下滚动到足以保证加载更多项目的程度.Soup.io 的实现似乎在您向下滚动时删除了旧项目,这样浏览器就不会处理越来越大的 DOM 树.哪些 javascript 库最适合这项任务?

I am building a blog type page, and I want to load items into the page as the user scrolls down, much like Google Reader, or Soup.io. How would you go about achieving this effect? I've seen some examples which read the height of the page, and have an onScroll even attached to the window so that as the user scrolls down we can test to see if they've scrolled down far enough to warrant loading more items. Soup.io's implementation seems to remove the old items as you scroll down so that the browser isn't dealing with an ever-increasingly large DOM tree. Which javascript libraries would be best suited to this task?

推荐答案

Unspace 有一篇文章展示了此功能:无尽的Pageless:没有更多的下一页.他们的演示页面在这里(已死,供参考).

Unspace had an article demonstrating this functionality: Endless Pageless: No More Next Page. Their demonstration page is here (dead, for reference).

此特定示例使用 RoR 和 Prototype.

This particular example uses RoR and Prototype.

这篇关于在用户向下滚动时加载内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆