Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Fetch on scrolling up, not bottom #14

Open
hazzo opened this issue Jun 8, 2017 · 7 comments
Open

Feature: Fetch on scrolling up, not bottom #14

hazzo opened this issue Jun 8, 2017 · 7 comments

Comments

@hazzo
Copy link

hazzo commented Jun 8, 2017

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.

@hilongjw
Copy link
Owner

hilongjw commented Jun 8, 2017

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

@hazzo
Copy link
Author

hazzo commented Jun 8, 2017

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?

@hilongjw
Copy link
Owner

hilongjw commented Jun 9, 2017

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☹️.

@hazzo
Copy link
Author

hazzo commented Jun 9, 2017

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?

@Textras
Copy link

Textras commented Jun 16, 2017

@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)

@agaripian
Copy link

agaripian commented Jul 15, 2017

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.

@hazzo
Copy link
Author

hazzo commented Jul 15, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants