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

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

问题描述

用于分页的模式目前在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?

推荐答案

money.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.

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

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