Open vikasprogrammer opened 8 years ago
Sounds like a great addition. PRs welcome.
Thanks!
I tried it with the following code and failed miserably, will really appreciate your help here. :
Scroll.prototype.last = function(lastNumRecords, totalRecords) {
if( this.hasNext() ) {
this.end = totalRecords;
this.start = totalRecords - lastNumRecords;
this.cache.moveTo(this.start, this.end - this.start);
}
};
I wanted to determine totalRecords
on the fly once this code started working. :(
Sorry, I assumed this was related to Paginate. That's the only context where this makes sense.
Infinite scroll, by definition, should be able to handle an infinite number of records, and thus it won't be able to go to the end of the list or count the number of records. The solution here would be to store an attribute on the records that puts them in descending order, and then use that as the sort field.
I have a timestamp
field which is added to records as they get added. There is no way to sort records in descending order. Only best thing is to use setWithPriority
. Is that right approach?
Change your timestamp field to a negative value, so they are ordered descending.
Yupe, found that solution. Thanks @katowulf
PS: I am using negative timestamp in the $priority
field.
Any reason to not simply store it in a invertedTimestamp
field? That way
you won't depend on a hidden property.
On Wed, Dec 16, 2015 at 8:31 AM vikasprogrammer notifications@github.com wrote:
PS: I am using negative timestamp in the $priority field.
— Reply to this email directly or view it on GitHub https://github.com/firebase/firebase-util/issues/79#issuecomment-165165470 .
No reason, I am just exploring various options. I think your suggestion has a valid point.
PS: @puf This question for the app https://instantchat.io, you liked in the Firebase's Google group.
I use this function to set priority for decending order.
function priority(){ var now = new Date().getTime(); return -1 * now; }
I have a usecase wherein I need to move to the last of the
ref
initially and then call severalprev()
s to move back in the list.Somthing like
scrollRef.scroll.last(25);
Is this possible?