pavelbabenko / react-native-awesome-gallery

Performant, native-like, and well-customizable gallery for React Native.
MIT License
498 stars 54 forks source link

Infinite list? #67

Closed wtlgo closed 5 months ago

wtlgo commented 8 months ago

The description of the library says that it supports an "Infinite list", but I can't figure out how to achieve that. May someone explain, please?

pavelbabenko commented 8 months ago

@wtlgo It means that when you have e.g 5 items, and you're on item-4 (the last one), you will see item-0 on the right side, so you can infinitely scroll with a loop

wtlgo commented 8 months ago

Oh, wouldn't that be called a "looped" gallery then? Well, anyway. If so, is there any way to feed ~300k items into the gallery without exploding? The performance monitor shows that it tries to render all 300k views at once, and it is a very computationally intensive task. I came up with an idea to split it into batches of 10 and then feed only 3 batches at once. And whenever the index goes out of the range [10, 20) I switch to another 3 batches and replace the index with 10 or 20 respectfully via ref.current.setIndex(idx). It works, but whenever it switches between batches I get an ugly "blink" because the data and the index are updated at the same time. So, maybe there's a better way?

zzorba commented 5 months ago

@wtlgo did you ever find a solution for this problem, I'm facing the same issue.

wtlgo commented 5 months ago

@zzorba I described my approach earlier. This library doesn't have an infinite gallery feature, only a looped one.

pavelbabenko commented 5 months ago

Fixed in v0.4.0

wtlgo commented 5 months ago

I'm sorry for asking, but I'm unable to understand how exactly it is fixed in the new update. Did you add the feature in question? If so, how do we use it?

pavelbabenko commented 5 months ago

@wtlgo There was a container for each item in previous versions. That's why when you pass 100 items to gallery, it was rendering 100 containers, but there were only e.g 5 images rendered (controlled by numToRender). In 0.4.0 I've removed those containers, so just fixed amount of views are rendered. You can try and let me know if it works well