-
Notifications
You must be signed in to change notification settings - Fork 163
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
Adding more slides via infinite scroll causes the carousel to reslide #330
Comments
@CitizenBeta this doesn't look like a "freakout" - it looks like it is doing a re-render. You are adding new Slides to the Slider as you are navigating through it? |
@tim-steele Freakout is probably a bad term to use here, my apologies haha. I think your analysis of a re-render is accurate; however, it is keeping the correct slide in focus once it finishes, and it's not resetting to the on-mount "currentSlide" so in my head it wasn't a full reset. Yes, I am adding new slides as I navigate. Once I get within 6 of the end, I add more to the end of the carousel. |
It doesn't need to do a reset of the state (currentSlide) - but it looks like when you are adding slides, it is forcing a re-render. |
@tim-steele is it possible to prevent that? Or pause animations or checking until after the additional slides are added? The current slide isn't changing, so I'm not sure why it would need to re-render. |
This isn't really a bug. We don't currently have a built-in way to do infinite scroll the way you are attempting to implement it. The container is re-rendering because you are adding additional slides, and using I am going to move this to a discussion, where people can discuss this infinite scroll solution. |
I guess to ask the question, is there another best practice towards having 1000+ slides? |
@CitizenBeta we have an infinite mode that takes you back to the beginning. This particular functionality we would be open to a pull request. I am not quite sure how it would be solved. |
I dont think the infinite mode is the same thing as infinite scroll. In this case it's really more of a limited scroll. The actual use case is using the carousel to view an album with 1400 photos. To load all of them at once seems kinda expensive. Loading 12 at a time seems like a good decision. |
I am also facing the same problem. After the object gets updated, the css properties |
pure-react-carousel
version: 1.27.6react
version: 17.0.1browser
used: Version 87.0.4280.88 (Official Build) (64-bit)node
version: v14.15.1Relevant code or config:
My carousel:
My slides:
What you did:
Add more slides via infinite scroll.
Problem description:
The slider freaks out for a second and returns to the correct current slide.
Gif/video example:
Suggested solution:
My thought was maybe this is happening because the index of the current item was changing, switching the Slide index=x to use to us the ID on the object instead of the index of the array didn't help:
The text was updated successfully, but these errors were encountered: