From 551185f651494790b3fe4b2e3fbcd9462ac36898 Mon Sep 17 00:00:00 2001 From: Daniel Pliego Date: Thu, 10 Dec 2015 16:45:13 -0600 Subject: [PATCH 1/6] Add background color property --- Carousel.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Carousel.js b/Carousel.js index 56f1d97..611c90f 100644 --- a/Carousel.js +++ b/Carousel.js @@ -31,6 +31,7 @@ var Carousel = React.createClass({ animate: true, delay: 1000, loop: true, + backgroundColor: 'transparent' }; }, @@ -135,7 +136,7 @@ var Carousel = React.createClass({ return ( Date: Fri, 1 Apr 2016 11:37:37 -0600 Subject: [PATCH 2/6] change carousel styles --- Carousel.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/Carousel.js b/Carousel.js index 611c90f..06b1848 100644 --- a/Carousel.js +++ b/Carousel.js @@ -168,18 +168,12 @@ var styles = StyleSheet.create({ position: 'absolute', flexDirection: 'row', flex: 1, + top: 150, justifyContent: 'space-around', alignItems: 'center', - backgroundColor:'transparent', - }, - pageIndicatorTop: { - top: 250, alignSelf: 'center', + backgroundColor:'transparent', }, - pageIndicatorBottom: { - bottom: 250, - alignSelf: 'center', - } }); module.exports = Carousel; From bceebfe11079b841e6e1452c38be15c8412fc987 Mon Sep 17 00:00:00 2001 From: Daniel Pliego Date: Fri, 1 Apr 2016 11:46:17 -0600 Subject: [PATCH 3/6] correct padding-top --- Carousel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Carousel.js b/Carousel.js index 86aec8b..d654af7 100644 --- a/Carousel.js +++ b/Carousel.js @@ -157,7 +157,7 @@ var styles = StyleSheet.create({ position: 'absolute', flexDirection: 'row', flex: 1, - top: 150, + top: 190, justifyContent: 'space-around', alignItems: 'center', alignSelf: 'center', From 02f42a8e06f1c1e2ca52c0583d8bc8ce8a1e9fdd Mon Sep 17 00:00:00 2001 From: Daniel Pliego Date: Fri, 1 Apr 2016 13:06:23 -0600 Subject: [PATCH 4/6] hide if < 1 --- Carousel.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Carousel.js b/Carousel.js index d654af7..8c7d347 100644 --- a/Carousel.js +++ b/Carousel.js @@ -73,9 +73,11 @@ var Carousel = React.createClass({ }; position.left = (this.props.width - position.width) / 2; - for (var i = 0, l = this.props.children.length; i < l; i++) { - style = i === this.state.activePage ? { color: this.props.indicatorColor } : { color: this.props.inactiveIndicatorColor }; - indicators.push(); + if (this.props.children.length > 1) { + for (var i = 0, l = this.props.children.length; i < l; i++) { + style = i === this.state.activePage ? { color: this.props.indicatorColor } : { color: this.props.inactiveIndicatorColor }; + indicators.push(); + } } return ( From 67c369203dcbf8fa016a1296c97d679f5ec8713d Mon Sep 17 00:00:00 2001 From: Juan Carlos Rojas Date: Wed, 13 Apr 2016 15:59:56 -0500 Subject: [PATCH 5/6] Fix bug when pressing an indicator with a custom width. --- Carousel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Carousel.js b/Carousel.js index 2a57da4..6b828de 100644 --- a/Carousel.js +++ b/Carousel.js @@ -55,7 +55,7 @@ var Carousel = React.createClass({ indicatorPressed(activePage){ this.setState({activePage}); - this.refs.scrollView.scrollTo({y:0, x:activePage * width}); + this.refs.scrollView.scrollTo({y:0, x:activePage * this.props.width}); }, renderPageIndicator() { From 1d7284947b348a3349395d8481aa822b59856ca6 Mon Sep 17 00:00:00 2001 From: danpliego Date: Wed, 13 Apr 2016 16:27:30 -0500 Subject: [PATCH 6/6] Add method to sync carousel location with current image --- Carousel.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Carousel.js b/Carousel.js index d9a07cf..da93e9e 100644 --- a/Carousel.js +++ b/Carousel.js @@ -54,6 +54,11 @@ var Carousel = React.createClass({ } }, + syncCarouselLocation() { + var width = this.state.activePage * this.props.width; + this.refs.scrollView && this.refs.scrollView.scrollWithoutAnimationTo(0, width); + }, + indicatorPressed(activePage){ this.setState({activePage}); this.refs.scrollView.scrollTo({y:0, x:activePage * this.props.width});