diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..c57bab1 Binary files /dev/null and b/.DS_Store differ diff --git a/README.md b/README.md index 4d2963e..1818435 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,7 @@ Also check out the three examples files: the [simple example](examples/Simple.js * `flatlistProps` (optional): additional props for the [FlatList](https://facebook.github.io/react-native/docs/flatlist.html) which holds all the pages. * `transitionAnimationDuration` (optional): The duration in milliseconds for the animation of the background color for the page transition. Defaults to `500`. * `allowFontScaling` (optional): Font scaling can cause troubles with high-resolution screens. You may want to disable it. Defaults to `true`. +* `givePageIndex` (optional): a function that receives the page `index` as a parameter. ## Custom Components Properties diff --git a/src/index.js b/src/index.js index abf9a84..f848b1c 100755 --- a/src/index.js +++ b/src/index.js @@ -47,6 +47,7 @@ class Onboarding extends Component { return; this.setState(state => { + this.props.givePageIndex(viewableItems[0].index); return { previousPage: state.currentPage, currentPage: viewableItems[0].index, @@ -109,6 +110,7 @@ class Onboarding extends Component { DotComponent, flatlistProps, skipToPage, + givePageIndex, } = this.props; const currentPage = pages[this.state.currentPage]; const currentBackgroundColor = currentPage.backgroundColor; @@ -231,6 +233,7 @@ Onboarding.propTypes = { subTitleStyles: Text.propTypes.style, transitionAnimationDuration: PropTypes.number, skipToPage: PropTypes.number, + givePageIndex: PropTypes.func, }; Onboarding.defaultProps = { @@ -255,6 +258,7 @@ Onboarding.defaultProps = { subTitleStyles: null, transitionAnimationDuration: 500, skipToPage: null, + givePageIndex: null, }; const styles = {