Compare commits

...

3 Commits

Author SHA1 Message Date
Daisuke Inoue
dcc2171c62 Updates src/index.js 2016-07-29 15:50:36 +09:00
Daisuke Inoue
d15df1cb32 Change experimental property "removeClippedSubviews" 's default value from true to false.
because this property has bad influence on animation of transition between pages.
2016-07-29 15:48:55 +09:00
Daisuke Inoue
69376b9bd4 Use scrollView for android 2016-07-29 08:35:57 +09:00
2 changed files with 18 additions and 45 deletions

21
dist/index.js vendored
View File

@ -153,7 +153,7 @@ module.exports = _react2.default.createClass({
showsVerticalScrollIndicator: false,
bounces: false,
scrollsToTop: false,
removeClippedSubviews: true,
removeClippedSubviews: false,
automaticallyAdjustContentInsets: false,
showsPagination: true,
showsButtons: false,
@ -388,11 +388,7 @@ module.exports = _react2.default.createClass({
if (state.dir === 'x') x = diff * state.width;
if (state.dir === 'y') y = diff * state.height;
if (_reactNative.Platform.OS === 'android') {
this.refs.scrollView && this.refs.scrollView.setPage(diff);
} else {
this.refs.scrollView && this.refs.scrollView.scrollTo({ x: x, y: y });
}
this.refs.scrollView && this.refs.scrollView.scrollTo({ x: x, y: y });
// update scroll state
this.setState({
@ -551,7 +547,7 @@ module.exports = _react2.default.createClass({
);
},
renderScrollView: function renderScrollView(pages) {
if (_reactNative.Platform.OS === 'ios') return _react2.default.createElement(
return _react2.default.createElement(
_reactNative.ScrollView,
_extends({ ref: 'scrollView'
}, this.props, this.scrollViewPropOverrides(), {
@ -562,15 +558,6 @@ module.exports = _react2.default.createClass({
onScrollEndDrag: this.onScrollEndDrag }),
pages
);
return _react2.default.createElement(
_reactNative.ViewPagerAndroid,
_extends({ ref: 'scrollView'
}, this.props, {
initialPage: this.props.loop ? this.state.index + 1 : this.state.index,
onPageSelected: this.onScrollEnd,
style: { flex: 1 } }),
pages
);
},
@ -626,4 +613,4 @@ module.exports = _react2.default.createClass({
this.props.showsButtons && this.renderButtons()
);
}
});
});

View File

@ -141,7 +141,7 @@ module.exports = React.createClass({
showsVerticalScrollIndicator : false,
bounces : false,
scrollsToTop : false,
removeClippedSubviews : true,
removeClippedSubviews : false,
automaticallyAdjustContentInsets : false,
showsPagination : true,
showsButtons : false,
@ -367,11 +367,7 @@ module.exports = React.createClass({
if(state.dir === 'x') x = diff * state.width
if(state.dir === 'y') y = diff * state.height
if (Platform.OS === 'android') {
this.refs.scrollView && this.refs.scrollView.setPage(diff)
} else {
this.refs.scrollView && this.refs.scrollView.scrollTo({ x, y })
}
this.refs.scrollView && this.refs.scrollView.scrollTo({ x, y })
// update scroll state
this.setState({
@ -521,28 +517,18 @@ module.exports = React.createClass({
},
renderScrollView(pages) {
if (Platform.OS === 'ios')
return (
<ScrollView ref="scrollView"
{...this.props}
{...this.scrollViewPropOverrides()}
contentContainerStyle={[styles.wrapper, this.props.style]}
contentOffset={this.state.offset}
onScrollBeginDrag={this.onScrollBegin}
onMomentumScrollEnd={this.onScrollEnd}
onScrollEndDrag={this.onScrollEndDrag}>
{pages}
</ScrollView>
);
return (
<ViewPagerAndroid ref="scrollView"
{...this.props}
initialPage={this.props.loop ? this.state.index + 1 : this.state.index}
onPageSelected={this.onScrollEnd}
style={{flex: 1}}>
{pages}
</ViewPagerAndroid>
);
return (
<ScrollView ref="scrollView"
{...this.props}
{...this.scrollViewPropOverrides()}
contentContainerStyle={[styles.wrapper, this.props.style]}
contentOffset={this.state.offset}
onScrollBeginDrag={this.onScrollBegin}
onMomentumScrollEnd={this.onScrollEnd}
onScrollEndDrag={this.onScrollEndDrag}>
{pages}
</ScrollView>
);
},
/**