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

Commit 3fcb70f

Browse files
mokesmokesajoslin
mokesmokes
authored andcommitted
fix(carousel): fix error with deleting multiple slides at once
1 parent 6a4527b commit 3fcb70f

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/carousel/carousel.js

+2
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ angular.module('ui.bootstrap.carousel', ['ui.bootstrap.transition'])
159159
} else {
160160
self.select(slides[index]);
161161
}
162+
} else if (currentIndex > index) {
163+
currentIndex--;
162164
}
163165
};
164166
}])

src/carousel/test/carousel.spec.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,13 @@ describe('carousel', function() {
192192
});
193193

194194
it('should remove slide from dom and change active slide', function() {
195-
scope.$apply('slides[1].active = true');
196-
testSlideActive(1);
197-
scope.$apply('slides.splice(1,1)');
195+
scope.$apply('slides[2].active = true');
196+
testSlideActive(2);
197+
scope.$apply('slides.splice(0,1)');
198198
expect(elm.find('div.item').length).toBe(2);
199199
testSlideActive(1);
200+
$timeout.flush();
201+
testSlideActive(0);
200202
scope.$apply('slides.splice(1,1)');
201203
expect(elm.find('div.item').length).toBe(1);
202204
testSlideActive(0);

0 commit comments

Comments
 (0)