react-native-slideshow icon indicating copy to clipboard operation
react-native-slideshow copied to clipboard

Dot Page indicator not working.

Open msameerbm opened this issue 6 years ago • 2 comments

If i click, the arrow button on left and right slider will work correctly and also the bullet dot page indicators changing correctly, but if i swipe via hands to next slide, The paging dot indicators does not changes.

msameerbm avatar Apr 07 '18 10:04 msameerbm

I had to change the component to make it work. To scroll as a slider when dragging (currently you can scroll the images partially) I had to add pagingEnabled to the ScrollView component.

Secondly, when the scroll is finished I had to update the bullets (the thing you were asking for). For this I added two handlers for the ScrollView:

   onScrollEndDrag={this.onScrollCustom}
   onMomentumScrollEnd={this.onScrollCustom}

And now the magic:

onScrollCustom = (e) =>{
    let contentOffset = e.nativeEvent.contentOffset;
    let viewSize = e.nativeEvent.layoutMeasurement;
    let pageNum = Math.floor(contentOffset.x / viewSize.width);
    console.log('New page ', pageNum);
    this.setState({position: pageNum});
  }

We need to calculate the current slide in order to update correctly the active bullet.

That's it! I know the solution is workaround-ish, but the component needs some polishing. The changes were made to a local component, to avoid overriding the changes by an eventual update.

alexpopa-work avatar Jul 31 '18 14:07 alexpopa-work

Where should I put "onScrollCustom" function?

hdmonster avatar Oct 18 '18 23:10 hdmonster