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

Index not updating #4

Closed
subpublic opened this issue Apr 28, 2015 · 5 comments
Closed

Index not updating #4

subpublic opened this issue Apr 28, 2015 · 5 comments

Comments

@subpublic
Copy link

Hello.

I've bound onMomentumScrollEnd and there I'm console logging the ref to my Swiper.
The state.index is always set to 0.

Is that a bug or is there another way to find out which node is viewed?

@subpublic
Copy link
Author

Seems like if I don't bind onMomentumScrollEnd, the index updates.
So when binding onTouchStartCapture everything works better.

Still not sure if that was a bug, but this works for me.

@leecade
Copy link
Owner

leecade commented Apr 28, 2015

Thanks @subpublicanders

First update index, then call onMomentumScrollEnd, is this helpfully? or I am very pleased to follow up your problem.

/**
   * Scroll end handle
   * @param  {object} e native event
   */
  onScrollEnd(e) {

    // update scroll state
    this.setState({
      isScrolling: false
    })

    let offset = e.nativeEvent.contentOffset
    this.updateIndex(offset, this.state.dir)

    // if `onMomentumScrollEnd` registered will be called here
    this.props.onMomentumScrollEnd && this.props.onMomentumScrollEnd.call(this)
  },

@subpublic
Copy link
Author

Well, I solved it by not using onMoementumScrollEnd at all.
If i bind onMoementumScrollEnd in my Swiper-jsx, then the onScrollEnd is never even called.
I set a console.log in your code to try it. Could it have something to do with the default render (line 389)? That it gets overridden.

@leecade
Copy link
Owner

leecade commented Apr 29, 2015

oh yes, onMoementumScrollEnd be overridden, thanks, i will fix it later.

leecade pushed a commit that referenced this issue Apr 29, 2015
TFsky pushed a commit to TFsky/react-native-swiper that referenced this issue Mar 14, 2018
* TypeError: Cannot assign to read only property 'onScroll' of object…
@ursnj
Copy link

ursnj commented Aug 21, 2019

@leecade when im loading content from some rest service, onMomentumScrollEnd and onIndexxhanged related is not working till the response returns back to the application from API. can you have any idea on this ???

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

3 participants