mirror of
https://github.com/zhigang1992/react-native-swiper.git
synced 2026-01-12 22:51:00 +08:00
Fixes #81
* Added .idea directory to gitignore WebStorm files * Issue #81 was related to missing prop `onPageSelected` on `ViewPagerAndroid`
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -32,3 +32,6 @@ build/Release
|
||||
*.xcuserstate
|
||||
examples/swiper.xcodeproj/project.xcworkspace/
|
||||
examples/swiper.xcodeproj/xcuserdata
|
||||
|
||||
# IntelliJ
|
||||
.idea/
|
||||
|
||||
10
dist/index.js
vendored
10
dist/index.js
vendored
@@ -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
|
||||
);
|
||||
|
||||
10
src/index.js
10
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 (
|
||||
<ViewPagerAndroid ref="scrollView"
|
||||
onPageSelected={this.onScrollEnd}
|
||||
style={{flex: 1}}>
|
||||
{pages}
|
||||
</ViewPagerAndroid>
|
||||
|
||||
Reference in New Issue
Block a user