react-native-masonry icon indicating copy to clipboard operation
react-native-masonry copied to clipboard

How will i do a pagination or lazy loading?

Open arunkrishna39 opened this issue 8 years ago • 36 comments

arunkrishna39 avatar Jul 18 '17 12:07 arunkrishna39

Your issue doesn't follow our guidelines. Please fix the following:

  • Issue description cannot be empty (?)

Click here for details.

Thank you! :pray: This comment was made by GitMagic – Magically enforcing your contribution guidelines.

ghost avatar Jul 18 '17 12:07 ghost

Hey @arunkrishna39, Sorry I don't have either functionality implemented, but I do plan on implementing Lazy Loading when my current application development process is at this stage.

brh55 avatar Jul 18 '17 15:07 brh55

@brh55 Eagerly waiting! Any time estimates?

srameshr avatar Jul 22 '17 11:07 srameshr

@brh55 Now that masonry implements flatlist, we should have this feature with onEndReached and ListFooterComponent right?

srameshr avatar Sep 07 '17 10:09 srameshr

@srameshr I believe the answer is no, not yet. @brh55's implementation of FlatList has not been merged yet. See #39

kmcgill88 avatar Sep 07 '17 13:09 kmcgill88

@kmcgill88 Flatlist has been merged, but the FlatList has been wrapped by a ListView which has been deprecated.

srameshr avatar Sep 26 '17 08:09 srameshr

@srameshr do you think that if we add our own implementation in FlatList's onEndReached() and onRefresh(), we could do ininite scroll/pagination out of the box?

vvavepacket avatar Sep 27 '17 04:09 vvavepacket

What I am doing right now is, passing refresh component to ListView. Can you do a FlatList rewrite of the ListView implementation under Masonry.js

srameshr avatar Sep 27 '17 04:09 srameshr

I've done a FlatList rewrite within the experiment branch -- it works, but not efficiently. Looks to be some sort of delay with the re-render time.

brh55 avatar Sep 27 '17 17:09 brh55

guys, I dig deep into the code, and saw that FlatList is present inside Column.js (master branch). Now, I tried to add methods like onEndReached(). I noticed it is called during rendering when images are loading.. But if I try to manually scroll down, it doesn't get called. Any idea what to do so we can have FlatList's onEndReached() method works to enable pagination?

vvavepacket avatar Oct 01 '17 17:10 vvavepacket

@brh55 can you confirm that FlatList rewrite is only for 0.3.x version? @srameshr do you mean to create a FlatList rewrite for the master/0.4.x/latest one?

vvavepacket avatar Oct 02 '17 00:10 vvavepacket

@brh55 @vvavepacket I am on the master branch and there is a big delay during inital rendering.

There are two things here:

  1. These is a ListView inside Masonry.js
  2. There WAS list view inside Column.js but now it has been converted to flat list.

I am guessing that the ListView inside Masonry.js is responsible for the terrible rendering time.

srameshr avatar Oct 02 '17 03:10 srameshr

If ListView is responsible then it's most likely the dataSource diff function. A quick way to check this is with removing line 19 + 42 in masonry, and replacing rowHasChanged with returning true and seeing if perhaps this is where the issue may lie.

brh55 avatar Oct 02 '17 17:10 brh55

@srameshr Could you give that a try on your app, and see if you notice any improvements?

brh55 avatar Oct 02 '17 17:10 brh55

@brh55 Nope! Its still the same. It takes 15 seconds to render just one image.

srameshr avatar Oct 03 '17 03:10 srameshr

@brh55 I got it. I think its because of the remote images. If I serve it with static images, it renders in a flash but when the images are remote, it takes 15 seconds at minimum. I'm assuming its because you are calculating the dimensions of the image before rendering. Is it possible to just render the grid with minimumHeight and then insert images after it has been downloaded and the dimensions are calculated?

My bad! My images take 14 seconds to download on a web browser! Crazy! Im on AWS M4 xLarge instance.

srameshr avatar Oct 03 '17 03:10 srameshr

What are your image sizes? It's deceiving on the apps and this component because they are resizing, but good role of thumb is 300kb or less. Unless it's high def is important of course.

brh55 avatar Oct 03 '17 16:10 brh55

2.7 MB 😝 Im using a resizer now!

srameshr avatar Oct 03 '17 16:10 srameshr

@srameshr best way to kill my bandwidth 🗡

brh55 avatar Oct 03 '17 16:10 brh55

@brh55 Sorry for that. Il make sure I cross verify before posting an issue.

srameshr avatar Oct 03 '17 16:10 srameshr

@srameshr haha no worries

brh55 avatar Oct 03 '17 16:10 brh55

Were you guys able to implement pagination by using flatlist's onRefresh/onEndReached() methods?

vvavepacket avatar Oct 03 '17 16:10 vvavepacket

@vvavepacket Since the Masonry.js file still has ListView, I do something like https://github.com/brh55/react-native-masonry/issues/51. See the last but one comment in that.

srameshr avatar Oct 03 '17 16:10 srameshr

@srameshr i see that #51 is for pull to refresh. Did you tried about doing continous loading, like when user reaches bottom of list, the flatlist will continosuly fetch new data and add it?

vvavepacket avatar Oct 03 '17 17:10 vvavepacket

No, I have not yet tried that. But hopefully by the time I need it, ListView gets replaced by FlatList under masonry which supports InfinteLoading and Pull to refresh.

srameshr avatar Oct 03 '17 17:10 srameshr

ezgif-4-2810d897af @brh55 I think the elements in the grid that are not downloaded should have an empty placeholder at least with a loading icon. See the demo attached. After I refresh the view, the GIF that is in the second position is not rendered until its completely loaded.

I would suggest just returning the header and footer with the actual image being a <ActivityIndicator /> or any placeholder with a certain height.

srameshr avatar Oct 03 '17 17:10 srameshr

Hello guys! How's it going?

Is it possible now to do loadMoreResults on onEndReached?

kesha-antonov avatar Oct 06 '17 08:10 kesha-antonov

@brh55 so infinite loading is a feature that lot of people are waiting for. FlatList provides it out of the box since it inherits ScrollView props.

So, until the ListView remains in Masonry.js, I dont think there is any way to provide this feature.

srameshr avatar Nov 12 '17 11:11 srameshr

@srameshr I feel you, give me some time to think about a good way to implement this. I have two possible ways, but unsure of potential side-effects and can foresee a lot of potential bugs arising

brh55 avatar Nov 13 '17 18:11 brh55

@brh55 let us know if u need to test out your idea :) we are ready testers any time :) , this feature looks promising and is in great need and will make plugin more awesome

vvavepacket avatar Feb 14 '18 11:02 vvavepacket