【发布时间】:2017-02-17 13:53:04
【问题描述】:
尝试做一个无限滚动页面,在用户滚动时显示元素。
所以每次我检测到滚动到达我调用的页面末尾时
this.recordLimit += 10;
this.subscribe('movements', {limit: this.recordLimit});
然后触发(自动运行)
this.autorun(h => {
if (this.ready()) {
this.items = Items.find(<potential limit filter here too>);
}
好的。那是有效的。但是每次调用this.items = Items.find(); 时,用户的浏览器都会向上滚动到顶部。
这可能是因为移除了 dom 元素,重置了滚动,然后再次添加了元素,而没有恢复之前的滚动位置。
我做错了什么?
“明显”工作的示例:
- https://github.com/barbatus/ng-infinite-scroll/blob/master/scroll-controller.js
- https://github.com/abecks/meteor-infinite-scroll
- http://meteorpedia.com/read/Infinite_Scrolling
@###########编辑############@
实际上,我注意到,在Items.find() 之后加上h.stop() 以停止订阅,这可行...我猜以前的芒果光标已更新为最后的订阅限制。
但是我仍然无法理解为什么这会在最初的情况下重新绘制所有内容..
【问题讨论】:
标签: meteor angular nginfinitescroll