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

state.index goes off the rail, internally inconsistent with state.offset.x #172

Open
fungilation opened this issue Jun 14, 2016 · 0 comments

Comments

@fungilation
Copy link
Contributor

fungilation commented Jun 14, 2016

I've written the following for debugging and attempt at correction. I observed that during quick swiping horizontally through my 10 horizontal child Scrollviews under react-native-swiper during heavy cpu use (rendering in said child Scrollviews), oftentimes index would go off the rails and be wrong.

My debugging code:

const onMomentumScrollEnd = (e, state, context) => {
  let index = Math.round(state.index)
  let offsetIndex = Math.round(state.offset.x / Dimensions.get('window').width - 1)
  if (index != offsetIndex) {
    console.log(`>>> Swiper.onMomentumScrollEnd offsetIndex ${offsetIndex} doesn't agree with index ${index}:`, state, context)
    index = offsetIndex
  }
}

index, when wrong, would always be smaller than it should be. offsetIndex would always be correct, corresponding to the correct Scrollview with data displayed within for that actual index.

This is obviously a problem as a wrong index loses the correct placement of child Scrollviews, and wrong display of the pager dots.

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