-
Notifications
You must be signed in to change notification settings - Fork 107
/
CarouselPager.ios.js
38 lines (33 loc) · 1017 Bytes
/
CarouselPager.ios.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
var React = require('react');
var createReactClass = require('create-react-class');
var {
ScrollView,
} = require('react-native');
var CarouselPager = createReactClass({
scrollToPage(page, animated) {
if (typeof animated === 'undefined') {
animated = true;
}
this.refs.scrollView.scrollTo({x: page * this.props.width, y: 0, animated: animated});
},
_onMomentumScrollEnd(e) {
var activePage = e.nativeEvent.contentOffset.x / this.props.width;
this.props.onEnd(activePage);
},
render() {
return <ScrollView ref="scrollView"
contentContainerStyle={this.props.contentContainerStyle}
automaticallyAdjustContentInsets={false}
horizontal={true}
pagingEnabled={true}
showsHorizontalScrollIndicator={false}
bounces={false}
onScrollBeginDrag={this.props.onBegin}
onMomentumScrollEnd={this._onMomentumScrollEnd}
scrollsToTop={false}
>
{this.props.children}
</ScrollView>;
},
});
module.exports = CarouselPager;