question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

snapToItem isn't snapping to the last item on android

See original GitHub issue

Cannot snap to the last item of the carousel using snapToItem(lastItemIndex, animated = …) on android, working fine on IOS; Note that when I call the method snapToItem() on any index except the last one it works fine. react-native-snap-carousel version 3.2.3

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

5reactions
bernardaklcommented, Sep 26, 2017

Hey, Yeah figured it out at last, In my application, I was adding a new item manually each time a button was pressed using a redux status. The problem was that on android, the new item wasn’t rendered fast enough, and the snapToItem function was running before the new item was rendered. I fixed it by adding a delay of 100 ms before running the snapToItem function each time the new item was added as the following: setTimeout( () => { this._carousel.snapToItem((this.props.containers.length) - 1, true); }, 100 ); this.props.containers contains the array of objects used to render the carousel items so (this.props.containers.length) - 1 is the index of the last item of the carousel.

0reactions
prestonbrown-mecommented, Aug 2, 2020

I edited one of the example snacks. This works on web, but not iOS.

Read more comments on GitHub >

github_iconTop Results From Across the Web

snapToItem isn't snapping to the last item on android #159
Cannot snap to the last item of the carousel using snapToItem(lastItemIndex, animated = ...) on android, working fine on IOS; Note that when ......
Read more >
react-native-snap-carousel, snapToItem does not move the ...
react-native-snap-carousel, snapToItem does not move the slider to a specific position when list length is more than 15 items.
Read more >
How to add Snap to alignment feature in FlatList in React Native
Now, FlatList component provides a way where an element from the list snaps itself to align the screen. This way, when the user...
Read more >
How To Snap Scrollable Items To The Center Of The Screen ...
By using a fling gesture, the item in focus at the end of the scroll animation should snap to the horizontal center of...
Read more >
react-native-snap-carousel - npm
Swiper component for React Native with previews and snapping effect. Compatible with Android & iOS. Pull requests are very welcome! Table of ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found