diff --git a/.gitignore b/.gitignore index dafc246..662faa4 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,6 @@ build/Release *.xcuserstate examples/swiper.xcodeproj/project.xcworkspace/ examples/swiper.xcodeproj/xcuserdata + +# IntelliJ +.idea/ diff --git a/dist/index.js b/dist/index.js index 4fd13fa..118a963 100644 --- a/dist/index.js +++ b/dist/index.js @@ -250,6 +250,15 @@ module.exports = _reactNative2.default.createClass({ isScrolling: false }); + // making our events coming from android compatible to updateIndex logic + if (!e.nativeEvent.contentOffset) { + if (this.state.dir == 'x') { + e.nativeEvent.contentOffset = { x: e.nativeEvent.position * this.state.width }; + } else { + e.nativeEvent.contentOffset = { y: e.nativeEvent.position * this.state.height }; + } + } + this.updateIndex(e.nativeEvent.contentOffset, this.state.dir); // Note: `this.setState` is async, so I call the `onMomentumScrollEnd` @@ -439,6 +448,7 @@ module.exports = _reactNative2.default.createClass({ return _reactNative2.default.createElement( _reactNative.ViewPagerAndroid, { ref: 'scrollView', + onPageSelected: this.onScrollEnd, style: { flex: 1 } }, pages ); diff --git a/src/index.js b/src/index.js index 92fa652..7d8ec3f 100644 --- a/src/index.js +++ b/src/index.js @@ -249,6 +249,15 @@ module.exports = React.createClass({ isScrolling: false }) + // making our events coming from android compatible to updateIndex logic + if (!e.nativeEvent.contentOffset) { + if (this.state.dir == 'x') { + e.nativeEvent.contentOffset = {x: e.nativeEvent.position * this.state.width} + } else { + e.nativeEvent.contentOffset = {y: e.nativeEvent.position * this.state.height} + } + } + this.updateIndex(e.nativeEvent.contentOffset, this.state.dir) // Note: `this.setState` is async, so I call the `onMomentumScrollEnd` @@ -430,6 +439,7 @@ module.exports = React.createClass({ ); return ( {pages}