snapToItem isn't snapping to the last item on android
See original GitHub issueCannot 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:
- Created 6 years ago
- Comments:12 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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 thesnapToItem
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.I edited one of the example snacks. This works on web, but not iOS.