Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Commit

Permalink
fix(carousel): fix sorting of indicators
Browse files Browse the repository at this point in the history
- Change the `orderBy` usage to `indexOfSlide` to properly order indicators

Closes #4071
Fixes #3764
  • Loading branch information
wesleycho committed Aug 2, 2015
1 parent ff37fb6 commit 8056368
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/carousel/carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ angular.module('ui.bootstrap.carousel', [])
var destroyed = false;
/* direction: "prev" or "next" */
self.select = $scope.select = function(nextSlide, direction) {
var nextIndex = self.indexOfSlide(nextSlide);
var nextIndex = $scope.indexOfSlide(nextSlide);
//Decide direction if it's not given
if (direction === undefined) {
direction = nextIndex > self.getCurrentIndex() ? 'next' : 'prev';
Expand Down Expand Up @@ -86,7 +86,7 @@ angular.module('ui.bootstrap.carousel', [])
};

/* Allow outside people to call indexOf on slides array */
self.indexOfSlide = function(slide) {
$scope.indexOfSlide = function(slide) {
return angular.isDefined(slide.index) ? +slide.index : slides.indexOf(slide);
};

Expand Down
2 changes: 1 addition & 1 deletion template/carousel/carousel.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div ng-mouseenter="pause()" ng-mouseleave="play()" class="carousel" ng-swipe-right="prev()" ng-swipe-left="next()">
<ol class="carousel-indicators" ng-show="slides.length > 1">
<li ng-repeat="slide in slides | orderBy:'index' track by $index" ng-class="{active: isActive(slide)}" ng-click="select(slide)"></li>
<li ng-repeat="slide in slides | orderBy:indexOfSlide track by $index" ng-class="{active: isActive(slide)}" ng-click="select(slide)"></li>
</ol>
<div class="carousel-inner" ng-transclude></div>
<a class="left carousel-control" ng-click="prev()" ng-show="slides.length > 1"><span class="glyphicon glyphicon-chevron-left"></span></a>
Expand Down

0 comments on commit 8056368

Please sign in to comment.