diff options
| author | Mark Otto <[email protected]> | 2014-06-09 22:25:00 -0700 |
|---|---|---|
| committer | Mark Otto <[email protected]> | 2014-06-09 22:25:00 -0700 |
| commit | 9ac3fe6fcfb5444d7fbde77f90e6546ea0a7b228 (patch) | |
| tree | ff3ef7a9f0c1583573c158e50e7d860fba7731ec | |
| parent | c7783f5ad8832e7046cd1d2fcdb7959bfa632c33 (diff) | |
| parent | 6a2482447dbc33519a966753e47607be9f199182 (diff) | |
| download | bootstrap-9ac3fe6fcfb5444d7fbde77f90e6546ea0a7b228.tar.xz bootstrap-9ac3fe6fcfb5444d7fbde77f90e6546ea0a7b228.zip | |
Merge branch 'master' of github.com:twbs/bootstrap
| -rw-r--r-- | js/carousel.js | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/js/carousel.js b/js/carousel.js index e2cb67a5e..f0117980d 100644 --- a/js/carousel.js +++ b/js/carousel.js @@ -48,16 +48,14 @@ return this } - Carousel.prototype.getActiveIndex = function () { - this.$active = this.$element.find('.item.active') - this.$items = this.$active.parent().children('.item') - - return this.$items.index(this.$active) + Carousel.prototype.getItemIndex = function (item) { + this.$items = item.parent().children('.item') + return this.$items.index(item || this.$active) } Carousel.prototype.to = function (pos) { var that = this - var activeIndex = this.getActiveIndex() + var activeIndex = this.getItemIndex(this.$active = this.$element.find('.item.active')) if (pos > (this.$items.length - 1) || pos < 0) return @@ -119,10 +117,8 @@ if (this.$indicators.length) { this.$indicators.find('.active').removeClass('active') - this.$element.one('slid.bs.carousel', function () { // yes, "slid" - var $nextIndicator = $(that.$indicators.children()[that.getActiveIndex()]) - $nextIndicator && $nextIndicator.addClass('active') - }) + var $nextIndicator = $(this.$indicators.children()[this.getItemIndex($next)]) + $nextIndicator && $nextIndicator.addClass('active') } var slidEvent = $.Event('slid.bs.carousel', { relatedTarget: relatedTarget, direction: direction }) // yes, "slid" |
