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

onSnapToItem inconsistent behaviour #185

Closed
louisholley opened this issue May 12, 2022 · 2 comments
Closed

onSnapToItem inconsistent behaviour #185

louisholley opened this issue May 12, 2022 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@louisholley
Copy link

Describe the bug
I have a carousel with 3 items - on load if i swipe right 4 times onSnapToItem logs

1
2
3
1

from here if i swipe left onSnapToItem logs

0
2
1
0

so it seems the direction you swipe in affects the behaviour of onSnapToItem which seems like a bug..

To Reproduce
Steps to reproduce the behavior:

  1. Render a carousel like:
 <Carousel
        width={300}
        height={150}
        data={[1, 2, 3]}
        onSnapToItem={(index) => console.log(index)}
        renderItem={({ item }) => (
          <Image
            style={{ width: 300, height: 150 }}
            source={{
              uri: 'https://images.unsplash.com/photo-1648737154547-b0dfd281c51e?ixlib=rb-1.2.1&ixid=MnwxMjA3fDF8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1740&q=80',
            }}
          />
        )}
      />
  1. Follow steps outlined in description to see inconsistent console logs

Additional context
Using react native on the web

@louisholley louisholley added the bug Something isn't working label May 12, 2022
@louisholley
Copy link
Author

workaround is to use index % data.length as the actual index within onSnapToItem

@dohooo
Copy link
Owner

dohooo commented May 14, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants