Skip to content
This repository has been archived by the owner on Dec 24, 2017. It is now read-only.

Commit

Permalink
Merge pull request #2 from bodyflex/master
Browse files Browse the repository at this point in the history
add simple support for android
  • Loading branch information
sunnylqm committed Dec 17, 2015
2 parents f03adb1 + 8b3f151 commit b79d970
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import React, {
ScrollView,
TouchableOpacity,
Dimensions,
Platform,
ViewPagerAndroid
} from 'react-native'

// Using bare setTimeout, setInterval, setImmediate
Expand Down Expand Up @@ -399,6 +401,26 @@ export default React.createClass({
)
},

renderScrollView(pages) {
if (Platform.OS === 'ios')
return (
<ScrollView ref="scrollView"
{...this.props}
contentContainerStyle={[styles.wrapper, this.props.style]}
contentOffset={this.state.offset}
onScrollBeginDrag={this.onScrollBegin}
onMomentumScrollEnd={this.onScrollEnd}>
{pages}
</ScrollView>
);
return (
<ViewPagerAndroid ref="scrollView"
style={{flex: 1}}>
{pages}
</ViewPagerAndroid>
);
},

/**
* Inject state to ScrollResponder
* @param {object} props origin props
Expand Down Expand Up @@ -466,14 +488,7 @@ export default React.createClass({
width: state.width,
height: state.height
}]}>
<ScrollView ref="scrollView"
{...props}
contentContainerStyle={[styles.wrapper, props.style]}
contentOffset={state.offset}
onScrollBeginDrag={this.onScrollBegin}
onMomentumScrollEnd={this.onScrollEnd}>
{pages}
</ScrollView>
{this.renderScrollView(pages)}
{props.showsPagination && (props.renderPagination
? this.props.renderPagination(state.index, state.total, this)
: this.renderPagination())}
Expand Down

0 comments on commit b79d970

Please sign in to comment.