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

Offset is ignored on first render when currentIndex != 0 #56

Open
deadlinc opened this issue May 31, 2019 · 2 comments
Open

Offset is ignored on first render when currentIndex != 0 #56

deadlinc opened this issue May 31, 2019 · 2 comments

Comments

@deadlinc
Copy link

When I set the currentIndex = 1, the offset is not applied until the sideswipe is interacted with. Setting the currentIndex = 0 works correctly.

First load (incorrect):
first-load

After Interaction (correct):
after-interaction

Thank you!

@rubycon
Copy link

rubycon commented Jun 20, 2019

I also have this issue but on component mount the carousel often end up between two slides.
The only way I can prevent this, is by delaying the index init/update with a setTimeout of 10ms. That's not very elegant but internally SideSwipe seems to do a similar thing:
https://github.com/kkemple/react-native-sideswipe/blob/master/src/carousel.js#L91

I suspect the issue is coming from the FlatList offset being computed before the slides layout are fully resolved or something like that. Maybe there's a better workaround using onLayout.

@kaplantm
Copy link

I'm also having this issue, and haven't had luck avoiding it with a setTimeout

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

3 participants