dohooo / react-native-reanimated-carousel

🎠 React Native swiper/carousel component, fully implemented using reanimated v2, support to iOS/Android/Web. (Swiper/Carousel)
https://react-native-reanimated-carousel.vercel.app
MIT License
2.72k stars 314 forks source link

Load infinite uncertain items #220

Open imyuanx opened 2 years ago

imyuanx commented 2 years ago

Is your feature request related to a problem? Please describe. I have many items to show, I put all items in data, But i don't think it's good, I think we can speed up by locking the length of the render items and async loading items, it can even to be loading infinite uncertain items.

Describe the solution you'd like I want to add hooks when add new items to the front or back of render list, At this point, we can loading async content before show this item.

imyuanx commented 2 years ago
image
dohooo commented 2 years ago

That's an interesting idea. Do you mean dynamically load data items and append them to a data array?

dohooo commented 2 years ago

And have you ever tried appending a new item to a data array dynamically?

imyuanx commented 2 years ago

That's an interesting idea. Do you mean dynamically load data items and append them to a data array?

I need to try. When i used other carousel library before, I noticed reset data array causes view re-render and page index confusion. Also in react-native-reanimated-carousel I need listen page index change, When near last page, Add new items to data array, but onScrollEnd will not be triggered untill the end of the animation, i must stop when continuous sliding to last page.

dohooo commented 2 years ago

emm, I tried to modify data length from 3 to 6, and current index is 2 ( the last item ), then I swipe the carousel, prop onScrollEnd works well. I think it works fine for data length changed. If you wanna a new carousel component, maybe you can set prop key to this

key={data.length}

This will get a new component and a fresh state. Thx for your detailed description. I will reopen this issue if you have any another question.

gigby commented 1 year ago

@dohooo Hi! I use your library the way how @yunying1 described (actually the lib can work as this guy said with no forking). It works well but not perfect (especially on android). I need throttle using nex/prev slide commands via ref and set scrollAnimationDuration about 1000. If you add this feature into app, the library will be the best swiper in the react-native world. As I can think there is no library which supports this way to use but this idea is not uniq at all.

imyuanx commented 1 year ago

In fact, I use this library to implement functions like TikTok (slide to the next page to dynamically load content), but in fact, this library is not designed for that kind of requirement, and there is no better solution at present.

dohooo commented 1 year ago

I am so sorry that I think I can solve all the problems you mentioned, but I have more important things to do at present, so I can only temporarily stop maintaining this project, but I will definitely come back and complete every feature you expect.

appsgenie commented 1 year ago

same here. looking for a way to append more data to the end as the user scrolls through the carousel.. I do this my updating the array that is setting the data property but after some 100 items it becomes very lagged and performance seems to slow down. there is also a "flash" like behavior when the next page is added and it looks like the carousel resets itself..

imyuanx commented 1 year ago

Influenced by this library, I created a simplified replacement: https://github.com/imyuanx/unlimited-carousel It might help you.

Nitrammets commented 6 months ago

Anyone found a good solution to this?