vue-recyclerview icon indicating copy to clipboard operation
vue-recyclerview copied to clipboard

Feature: Fetch on scrolling up, not bottom

Open hazzo opened this issue 7 years ago • 7 comments

I'm trying to implement this but I can get to figure it out.

I want to set delta (or is the anchorScroll?) to be offseted on the top. So only when user scrolls up the fetch function executes and unshifts more items to the recyclerview list. This only will be used in the case scenario that the user starts from the bottom.

Ex: items [a,b,c,d,e] Scrolls up. New items [f,g,h,i] => Items [f,g,h,i,a,b,c,d,e] (index will be in order i know, but not content]

This is the perfect way to implement this component for a chat option (Example: gitter, whatsapp, etc). Because if every item must by fetched by the component to scroll to last index the user experience will decay when you have thousands of items.

Thanks! If you could guide what should be done I can give a try and do a pull request.

hazzo avatar Jun 08 '17 08:06 hazzo

@hazzo I'm trying to implement dynamic on-demand loading, but there are still problems.here

hilongjw avatar Jun 08 '17 09:06 hilongjw

hmmmmmm but if you implement dynamic on-demand data it would be by using the fetch function? If it's like that how would you use the bottom scroll if you don't know the total elements of the list?

hazzo avatar Jun 08 '17 09:06 hazzo

The current pattern is that the data is linearly increased and the rendering mode is also from top to bottom layout, and I have not done a good solution to implement it☹️.

hilongjw avatar Jun 09 '17 07:06 hilongjw

Hmmmmmm. But how much it will change everything if for example:

  • Get a chunk of 50 items
  • Scroll to bottom of that 50 items
  • Scrolling up -> if > el.scrollTop = el.scrollHeight + offset > Trigger fetch & save position
  • New chunk of 50 -> unshift every element to array (so you don't modify items positions)
  • Calculate height of every element and as its been added to viewport scroll to saved position plus the added height to avoid to many jumps on scroll.
  • Once data it's loaded the DOM recycling behavior it's just the same as now.
  • Don't listen to scrolling down for fetching more data.

I know that maybe this is a tricky, but how this affects current rendering from top to bottom? I know that dynamic fetching could be kind of nightmare because you don't "know" where are you scrolling.

But as it is now only data it's being fetch on scroll down, why not only on scroll up and let this be decided by a prop in the component? What I mean, or you fetch data on scroll down or scroll up?

hazzo avatar Jun 09 '17 07:06 hazzo

@hazzo you're using variable sizes too, correct? Curious, are you having any mem issues or crashes say from too many different template heights? Or do you have only a cpl perhaps? (sorry for the side question)

Textras avatar Jun 16 '17 23:06 Textras

Looking to do the same exact thing with this component. I am trying to fetch data when user scrolls up to load older chat history. @hazzo any luck with this? Or did you go down another route.

agaripian avatar Jul 15 '17 23:07 agaripian

@agaripian I took another approach. I'm using computed property and benefiting of how vue manages everything in virtual DOM. So I load data on scroll up or down and then scrolling back to last known position. it's no fluent as this component but for sure more memory and time efficient. Every virtual list component I look does not get into consideration the possibility for multiple methods to load more data.

hazzo avatar Jul 15 '17 23:07 hazzo