Meteor 的最佳分页模式 [英] Best pattern for pagination for Meteor

查看:22
本文介绍了Meteor 的最佳分页模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

分页模式目前在 Meteor 1.0 之后的路线图上.现在有什么例子或建议如何做吗?那么如何在用户滚动到底部时通过订阅新元素和新元素来很好地进行无限滚动?

Pattern for pagination is currently on a after 1.0 roadmap for Meteor. Are there any examples or suggestions how to do it now? So how to nicely do an infinite scroll by subscribing to new and new elements as user is scrolling to the bottom?

推荐答案

aircraft.meteor.com 上有一个用于分页的包,可以帮助您入门

There is a package on atmosphere.meteor.com for pagination that should get you started

  • https://github.com/egtann/meteor-pagination (Pagination)
  • https://github.com/tmeasday/meteor-paginated-subscription (Pagination with publish)

第二个实际上一次发送一页数据,而不是一次发送所有数据,因此如果您有大量数据,它可能会有所帮助.使用无限滚动时,您必须附加一个手动滚动侦听器,并在向下滚动时增加页面大小(不是专门移动到第 2 页)来输入新数据.

The second one actually sends down one page of data at a go instead of all the data at once so if you have loads of data it might help with that. With the infinite scroll you would have to attach a manual scroll listener and put in the new data by increasing the size of a page as you scroll down (not specifically moving to page 2).

我有点不确定要具体使用什么模式,因为使用页面大小可能会有点麻烦,除非您能够通过反应性使其正常工作,如果您能够将 {{#each}} 阻止助手,以便每次向下滚动时,可能使用 Meteor.render 以便不会重新渲染已经可用的整个数据集.

I'm a bit unsure on what pattern to use specifically because using page size might be a bit troublesome unless you're able to get it to work right with reactivity which should be possible if you're able to seperate your {{#each}} block helpers so that its for each scroll down, perhaps using Meteor.render so that the entire set of data already available isn't re-rendered.

如果您将数据放在包含滚动溢出的 div 块中而不是上面的数据块中,它也可能起作用,以便它重新渲染但它们在滚动中的位置保持不变,实际上使重新渲染不明显.

It might also work if you put the data in div block containing a scroll overflow instead of the above so that it does re-render but their position in the scroll remains the same, in effect making the re-render unnoticable.

这篇关于Meteor 的最佳分页模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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