From 4eb73088305c4741e6f41b99ff7045429ca2b3a3 Mon Sep 17 00:00:00 2001 From: Atit Date: Mon, 8 Jan 2018 16:23:25 +0530 Subject: [PATCH] Allow user to manually stop autoplay --- Carousel.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Carousel.js b/Carousel.js index 00d899b..22998b1 100644 --- a/Carousel.js +++ b/Carousel.js @@ -31,6 +31,7 @@ var Carousel = createReactClass({ animate: true, delay: 1000, loop: true, + manualStop: false, }; }, @@ -114,11 +115,14 @@ var Carousel = createReactClass({ _animateNextPage() { var activePage = 0; - if (this.state.activePage < this.props.children.length - 1) { + if(this.props.manualStop == false) + { + if (this.state.activePage < this.props.children.length - 1) { activePage = this.state.activePage + 1; - } else if (!this.props.loop) { + } else if (!this.props.loop) { return; - } + } + } this.indicatorPressed(activePage); this._setUpTimer();