Trying to do an infinite scroll page that displays elements as the user scrolls.
So each time I detect that the scroll reaches the end of the page I call
this.recordLimit += 10;
this.subscribe('movements', {limit: this.recordLimit});
and that triggeres (autorun)
this.autorun(h => {
if (this.ready()) {
this.items = Items.find(<potential limit filter here too>);
}
All right. That is working. However each time this.items = Items.find();
is called, the user's browser is scrolled back up to the top.
Potentially this is because the dom elements are removed, the scroll is reset, and then the elements are added again without restoring the previous scroll position.
What am I doing wrong ?
Examples where it is 'apparenty' working:
- 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
@########### Edit ############@
Actually, I noticed that, putting after the Items.find()
a h.stop()
to stop the subscription, this works... I guess the previous mango cursor is updated with the last subscription limit.
However I am still not able to understand why this was repainting everything in the initial case..