From 566ed0707f434f6d8758719b3eedc3676935e3dc Mon Sep 17 00:00:00 2001 From: "I. Pinakoulakis" Date: Wed, 20 May 2015 18:08:57 +0200 Subject: [PATCH] Update rn-carousel.js due to issue on removed currentSlides. --- src/directives/rn-carousel.js | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/directives/rn-carousel.js b/src/directives/rn-carousel.js index 69a379d..4a5ecb6 100755 --- a/src/directives/rn-carousel.js +++ b/src/directives/rn-carousel.js @@ -382,13 +382,21 @@ if (iAttributes.rnCarouselAutoSlide!==undefined) { var duration = parseInt(iAttributes.rnCarouselAutoSlide, 10) || options.autoSlideDuration; scope.autoSlide = function() { - if (scope.autoSlider) { - $interval.cancel(scope.autoSlider); - scope.autoSlider = null; - } - scope.autoSlider = $interval(function() { - if (!locked && !pressed) { - scope.nextSlide(); + var cancelAutoSlider = function() { + if (scope.autoSlider) { + $interval.cancel(scope.autoSlider); + scope.autoSlider = null; + } + }; + cancelAutoSlider(); + scope.autoSlider = $interval(function() { + if (currentSlides === undefined) { + cancelAutoSlider(); + } + else { + if (!locked && !pressed) { + scope.nextSlide(); + } } }, duration * 1000); };