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

Removing last item from carousel results in an empty space (Android) #623

Open
5 tasks done
danvickers opened this issue Nov 20, 2019 · 11 comments
Open
5 tasks done

Comments

@danvickers
Copy link

Is this a bug report, a feature request, or a question?

Bug report

Have you followed the required steps before opening a bug report?

Have you made sure that it wasn't a React Native bug?

Yes as far as possible.

Is the bug specific to iOS or Android? Or can it be reproduced on both platforms?

Android

Is the bug reproducible in a production environment (not a debug one)?

Yes - it presents in a live version of our app

Environment

react-native-snap-carousel: 3.8.4
react-native@0.60.5
Android 9

Expected Behavior

When removing the last item from the data I expected the carousel to display the next available item as it does with start and middle list items and as it does on iOS.

Actual Behavior

An empty space is displayed

Reproducible Demo

https://snack.expo.io/@danjvee/react-native-snap-carousel-item-remove-bug---android

Steps to Reproduce

  1. Preview the code on Android
  2. Scroll right to the last item in the carousel.
  3. Tap the item delete button
  4. Observe the empty space
@DiegoMac95
Copy link

I have the same issue, a quick workaround I used was scrolling to the previous item after deleting.

@askemeline
Copy link

Hi, I have the same problem, can you explain more your solution @DiegoMac95 please

@ghost
Copy link

ghost commented Mar 11, 2020

Hello, we have the same issue here, could you provide us any detailed informations ?

@DiegoMac95
Copy link

DiegoMac95 commented Mar 11, 2020

@askemeline When I delete an element from the carousel, I also use snapToPrev method to scroll to the previous element, manually doing what the carousel does in iOS, that deletes the empty space.

@askemeline
Copy link

Thanks for your response but I don't really understand when you use it without the onPress. I would like that android do it automatically when I delete the last element :/

@DiegoMac95
Copy link

@askemeline that's why you need to add the reference like this

<Carousel
  // LIKE THIS
  ref={(c) => { this._carousel = c; }}
/>

// now you can call it wherever you have access to the reference of the carousel
deleteAndSnap = () => {
     deleteElement();
     this._carousel.snapToPrev(); 
}

You don't actually need to use 'onPress', you can call the method anywhere in your component using that reference

@askemeline
Copy link

Thanks for your answer but I have still the bug :/

@askemeline
Copy link

My bad, is working, many thanks @DiegoMac95 :)

@AlexReusC
Copy link

What can I do if I have enableSnap={false}?

@dohooo

This comment was marked as spam.

@wnikola
Copy link

wnikola commented Nov 28, 2023

Any updates on this? Still facing this issue.

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

6 participants