machadogj / react-native-carousel-control

React Native Carousel control with support for iOS and Android
MIT License
247 stars 55 forks source link

get index page when changes #15

Closed danielCrespo01 closed 7 years ago

danielCrespo01 commented 7 years ago

It is possible to obtain the index of the page with the function onPageChange this is my code: _onChangeCorousel() { console.log("this Carousel:",this); } <Carousel onPageChange={this._onChangeCorousel.bind(this)}>

machadogj commented 7 years ago

Hi @danielCrespo01 yes it's possible. You can see the code here:

https://github.com/machadogj/react-native-carousel-control/blob/master/index.js#L110

What you need to do is add a param to your callback:

_onChangeCorousel(index) { console.log("carousel index:", index); }

Let me know if that works for you.

danielCrespo01 commented 7 years ago

thank you very much @machadogj

machadogj commented 7 years ago

Welcome!