File tree Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Expand file tree Collapse file tree 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({
2929 indicatorSpace : 25 ,
3030 animate : true ,
3131 delay : 1000 ,
32- loop : true ,
32+ loop : true
3333 } ;
3434 } ,
3535
@@ -135,12 +135,17 @@ var Carousel = React.createClass({
135135 } ,
136136
137137 render ( ) {
138+ let width = this . getWidth ( )
139+ let style = {
140+ flex : 1 ,
141+ width : width
142+ }
143+
138144 return (
139- < View style = { { flex : 1 } } >
145+ < View style = { style } >
140146 < CarouselPager
141147 ref = "pager"
142- width = { this . getWidth ( ) }
143- contentContainerStyle = { styles . container }
148+ width = { width }
144149 onBegin = { this . _onAnimationBeginPage }
145150 onEnd = { this . _onAnimationEnd }
146151 >
Original file line number Diff line number Diff line change 11var React = require ( 'react' ) ;
22var {
33 ScrollView,
4+ View
45} = require ( 'react-native' ) ;
56
67var CarouselPager = React . createClass ( {
@@ -29,9 +30,13 @@ var CarouselPager = React.createClass({
2930 onMomentumScrollEnd = { this . _onMomentumScrollEnd }
3031 scrollsToTop = { false }
3132 >
32- { this . props . children }
33+ { React . Children . map ( this . props . children , this . setWidth ) }
3334 </ ScrollView > ;
3435 } ,
36+
37+ setWidth ( child ) {
38+ return ( < View style = { { width : this . props . width } } > { child } </ View > )
39+ }
3540} ) ;
3641
3742module . exports = CarouselPager ;
You can’t perform that action at this time.
0 commit comments