File tree 2 files changed +15
-5
lines changed
2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ var Carousel = React.createClass({
29
29
indicatorSpace : 25 ,
30
30
animate : true ,
31
31
delay : 1000 ,
32
- loop : true ,
32
+ loop : true
33
33
} ;
34
34
} ,
35
35
@@ -135,12 +135,17 @@ var Carousel = React.createClass({
135
135
} ,
136
136
137
137
render ( ) {
138
+ let width = this . getWidth ( )
139
+ let style = {
140
+ flex : 1 ,
141
+ width : width
142
+ }
143
+
138
144
return (
139
- < View style = { { flex : 1 } } >
145
+ < View style = { style } >
140
146
< CarouselPager
141
147
ref = "pager"
142
- width = { this . getWidth ( ) }
143
- contentContainerStyle = { styles . container }
148
+ width = { width }
144
149
onBegin = { this . _onAnimationBeginPage }
145
150
onEnd = { this . _onAnimationEnd }
146
151
>
Original file line number Diff line number Diff line change 1
1
var React = require ( 'react' ) ;
2
2
var {
3
3
ScrollView,
4
+ View
4
5
} = require ( 'react-native' ) ;
5
6
6
7
var CarouselPager = React . createClass ( {
@@ -29,9 +30,13 @@ var CarouselPager = React.createClass({
29
30
onMomentumScrollEnd = { this . _onMomentumScrollEnd }
30
31
scrollsToTop = { false }
31
32
>
32
- { this . props . children }
33
+ { React . Children . map ( this . props . children , this . setWidth ) }
33
34
</ ScrollView > ;
34
35
} ,
36
+
37
+ setWidth ( child ) {
38
+ return ( < View style = { { width : this . props . width } } > { child } </ View > )
39
+ }
35
40
} ) ;
36
41
37
42
module . exports = CarouselPager ;
You can’t perform that action at this time.
0 commit comments