diff --git a/src/carousel/carousel.js b/src/carousel/carousel.js index 3b99a20052..3ebdd12264 100644 --- a/src/carousel/carousel.js +++ b/src/carousel/carousel.js @@ -83,12 +83,22 @@ angular.module('ui.bootstrap.carousel', []) $scope.next = function() { var newIndex = (self.getCurrentIndex() + 1) % slides.length; + if (newIndex === 0 && $scope.noWrap()) { + $scope.pause(); + return; + } + return self.select(getSlideByIndex(newIndex), 'next'); }; $scope.prev = function() { var newIndex = self.getCurrentIndex() - 1 < 0 ? slides.length - 1 : self.getCurrentIndex() - 1; + if ($scope.noWrap() && newIndex === slides.length - 1){ + $scope.pause(); + return; + } + return self.select(getSlideByIndex(newIndex), 'prev'); }; @@ -225,7 +235,8 @@ angular.module('ui.bootstrap.carousel', []) scope: { interval: '=', noTransition: '=', - noPause: '=' + noPause: '=', + noWrap: '&' } }; }]) diff --git a/src/carousel/docs/README.md b/src/carousel/docs/README.md index 2c7d173adc..295378e0c4 100644 --- a/src/carousel/docs/README.md +++ b/src/carousel/docs/README.md @@ -3,3 +3,5 @@ Carousel creates a carousel similar to bootstrap's image carousel. The carousel also offers support for touchscreen devices in the form of swiping. To enable swiping, load the `ngTouch` module as a dependency. Use a `` element with `` elements inside it. It will automatically cycle through the slides at a given rate, and a current-index variable will be kept in sync with the currently visible slide. + +Use the no-wrap attribute on a `` element to control the looping of slides; setting no-wrap to an expression which evaluates to a truthy value will prevent looping diff --git a/src/carousel/docs/demo.html b/src/carousel/docs/demo.html index 3f7d13b25b..151528d43c 100644 --- a/src/carousel/docs/demo.html +++ b/src/carousel/docs/demo.html @@ -1,6 +1,6 @@
- +