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

scrollTo / scrollBy on mount fails (NaN) #1192

Open
mschipperheyn opened this issue Jun 17, 2020 · 0 comments
Open

scrollTo / scrollBy on mount fails (NaN) #1192

mschipperheyn opened this issue Jun 17, 2020 · 0 comments

Comments

@mschipperheyn
Copy link
Contributor

mschipperheyn commented Jun 17, 2020

Which OS ?

Android

Version

Which versions are you using:

  • react-native-swiper v1.6.0
  • react-native v61.x

Expected behaviour

When you call carouselRef.current.scrollTo(slides.length - 1, true);
it should transition to the last slide

Actual behaviour

It doesn't do anything bc his.internals.offset[dir] is undefined, leading
https://github.com/leecade/react-native-swiper/blob/master/src/index.js#L467 to result in NaN

Solution possibly:
const diff = offset[dir] - (this.internals.offset[dir] || 0)

How to reproduce it>

call scrollTo or scrollBy after mount before you swiped

Steps to reproduce

  1. mount component
  2. call carouselRef.current.scrollTo(slides.length - 1, true);
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

1 participant