mirror of
https://github.com/zhigang1992/react-native-swiper.git
synced 2026-04-30 21:22:44 +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
|
*.xcuserstate
|
||||||
examples/swiper.xcodeproj/project.xcworkspace/
|
examples/swiper.xcodeproj/project.xcworkspace/
|
||||||
examples/swiper.xcodeproj/xcuserdata
|
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
|
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);
|
this.updateIndex(e.nativeEvent.contentOffset, this.state.dir);
|
||||||
|
|
||||||
// Note: `this.setState` is async, so I call the `onMomentumScrollEnd`
|
// Note: `this.setState` is async, so I call the `onMomentumScrollEnd`
|
||||||
@@ -439,6 +448,7 @@ module.exports = _reactNative2.default.createClass({
|
|||||||
return _reactNative2.default.createElement(
|
return _reactNative2.default.createElement(
|
||||||
_reactNative.ViewPagerAndroid,
|
_reactNative.ViewPagerAndroid,
|
||||||
{ ref: 'scrollView',
|
{ ref: 'scrollView',
|
||||||
|
onPageSelected: this.onScrollEnd,
|
||||||
style: { flex: 1 } },
|
style: { flex: 1 } },
|
||||||
pages
|
pages
|
||||||
);
|
);
|
||||||
|
|||||||
10
src/index.js
10
src/index.js
@@ -249,6 +249,15 @@ module.exports = React.createClass({
|
|||||||
isScrolling: false
|
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)
|
this.updateIndex(e.nativeEvent.contentOffset, this.state.dir)
|
||||||
|
|
||||||
// Note: `this.setState` is async, so I call the `onMomentumScrollEnd`
|
// Note: `this.setState` is async, so I call the `onMomentumScrollEnd`
|
||||||
@@ -430,6 +439,7 @@ module.exports = React.createClass({
|
|||||||
);
|
);
|
||||||
return (
|
return (
|
||||||
<ViewPagerAndroid ref="scrollView"
|
<ViewPagerAndroid ref="scrollView"
|
||||||
|
onPageSelected={this.onScrollEnd}
|
||||||
style={{flex: 1}}>
|
style={{flex: 1}}>
|
||||||
{pages}
|
{pages}
|
||||||
</ViewPagerAndroid>
|
</ViewPagerAndroid>
|
||||||
|
|||||||
Reference in New Issue
Block a user