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

firstItem not working on Android #472

Open
schumannd opened this issue Feb 6, 2019 · 9 comments
Open

firstItem not working on Android #472

schumannd opened this issue Feb 6, 2019 · 9 comments

Comments

@schumannd
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

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

Android

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

yes

Environment

Environment:
React: 16.0.0-beta.5
React native: 0.51
react-native-snap-carousel: 3.3.4

Target Platform:
Android (6.0)
iOS (11)
-->

(Write your answer here.)

Expected Behavior

scroll to item number specified in firstItem

Actual Behavior

does not scroll

Reproducible Demo

  1. use firstItem on android.

This might be related to https://stackoverflow.com/questions/33208477/react-native-android-scrollview-scrollto-not-working

I fixed it when using scrollTo in my component in a hacky way by introducing a 200ms delay or so on android.

@bd-arc
Copy link
Contributor

bd-arc commented Feb 8, 2019

Can you please provide a Snack example in which the issue can be reproduced?

@eoghanmccarthy
Copy link

I am experiencing this too.

I have a list of 30 product pages. If item 0 - 5 is clicked to open as firstItem in the carousel it works as expected. However, clicking on any higher index in the list will result in index 5 always being the first visible item. Currently getting around it by using ScrollList on Android only.

@bd-arc
Copy link
Contributor

bd-arc commented Feb 18, 2019

@eoghanmccarthy I don't know if you're referring to the same issue. Yours is a well-known and unfortunate FlatList bug.

See #363 for more info. #250 seems like the only way to get rid of it...

@dolevp
Copy link

dolevp commented Mar 6, 2019

Is it possible that the problem exists only on RTL devices?

@AshishCd
Copy link

AshishCd commented Mar 19, 2019

Hey @eoghanmccarthy please use useScrollView into your Carousel component, it will solve your problem.

<Carousel data={photos} renderItem={this._renderItem} sliderWidth={sliderWidth} itemWidth={itemWidth} firstItem={this.state.selectedIndex} contentContainerCustomStyle={styles.sliderContentContainer} layout={"default"} loop={true} onSnapToItem={slideIndex => this.setState({ selectedIndex: slideIndex }) } useScrollView />

@radik
Copy link

radik commented May 23, 2019

@AshishCd you saved my day. Thank you.

@thekevinbrown
Copy link

@AshishCd this causes performance problems. I think this issue can be closed in favour of #538 as that has a simple reproduction case for both Android and iOS.

@ericvvc9
Copy link

@AshishCd Thank you

@dohooo

This comment was marked as spam.

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

9 participants