-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
snapToItem isn't snapping to the last item on android #159
Comments
Hi @bernardakl, I see that you've opened and closed this issue numerous times. Did you figure out what was the matter? |
Hey, |
Thanks for the feedback! This is pretty strange though; Android never fails to amaze as a source of surprising bugs. |
Most welcome. |
same issue |
I'm also having this issue and I'm not using a dynamic list, when I call snapToItem for the last item it snap to the second last item in the list. Edit: I tried using a 1 second delay before snapping but it didn't solve my issue |
@bd-arc it would take some time to make an isolated example to demonstrate the issue but I will do my best to give you as much information as possible. I'm displaying a list of pictures using a ListView (think of a picture gallery) and when the user tap on one of the pictures, I open a new view using react-native-navigation and I display the pictures using this plugin. What I'm trying to do is to display the pictures in the carousel and start at the position of the picture the user tapped on. When I tap the picture in the gallery, I pass the index of the picture to the new view and I use this index with the At first I thought it was only the last item that was not working properly because I only had 6 items in my gallery. From my tests, the first 5 items works like they should, but when the index is greater than 5, it will always display the 5th item. I also tried to remove the firstItem prop and use the snapToItem method with a delay after the component mount, but I get the same results. After the carousel is rendered, I can swipe to any slides without problem, it's only an issue of starting the carousel at the right position. This is only an issue on Android, it's working great using the same code on iOS. Let me know if I should make a new issue to track this, after some tests I'm not sure I'm having the same issue as OP. Thank you in advance for your help, have a good day |
@bd-arc Thank you! I will take a look at it. |
I am having this same issue. I'm trying to append a new card to a list given in the Carousel data prop. It is able to take me to the last item before the append to the list, but I always have to swipe one more time to get to the new element. Is it something wrong with my implementation? addCardHandler = () => {
let tempCard = new Map<string, string>();
for(let index in this.state.categories) {
tempCard.set(this.state.categories[index], '');
}
this.setState((previousState: ContentFields, currentProps) => {
return {
data: [...previousState.data, tempCard]
}
},
() => {
this._carousel?.snapToItem(this.state.data.length-1);
})
} |
I edited one of the example snacks. This works on web, but not iOS. |
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
The text was updated successfully, but these errors were encountered: