Skip to content

Commit

Permalink
change how carousel indicators activate #12592
Browse files Browse the repository at this point in the history
  • Loading branch information
ktzhu committed Jun 10, 2014
1 parent 2213a5b commit 5eaedbe
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions js/carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 5eaedbe

Please sign in to comment.