mirror of
https://github.com/twbs/bootstrap.git
synced 2024-11-29 11:24:18 +01:00
Merge pull request #13770 from twbs/fat-carousel
change how carousel indicators activate - fixes #12592
This commit is contained in:
commit
6a2482447d
@ -48,16 +48,14 @@
|
|||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
Carousel.prototype.getActiveIndex = function () {
|
Carousel.prototype.getItemIndex = function (item) {
|
||||||
this.$active = this.$element.find('.item.active')
|
this.$items = item.parent().children('.item')
|
||||||
this.$items = this.$active.parent().children('.item')
|
return this.$items.index(item || this.$active)
|
||||||
|
|
||||||
return this.$items.index(this.$active)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Carousel.prototype.to = function (pos) {
|
Carousel.prototype.to = function (pos) {
|
||||||
var that = this
|
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
|
if (pos > (this.$items.length - 1) || pos < 0) return
|
||||||
|
|
||||||
@ -119,10 +117,8 @@
|
|||||||
|
|
||||||
if (this.$indicators.length) {
|
if (this.$indicators.length) {
|
||||||
this.$indicators.find('.active').removeClass('active')
|
this.$indicators.find('.active').removeClass('active')
|
||||||
this.$element.one('slid.bs.carousel', function () { // yes, "slid"
|
var $nextIndicator = $(this.$indicators.children()[this.getItemIndex($next)])
|
||||||
var $nextIndicator = $(that.$indicators.children()[that.getActiveIndex()])
|
|
||||||
$nextIndicator && $nextIndicator.addClass('active')
|
$nextIndicator && $nextIndicator.addClass('active')
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var slidEvent = $.Event('slid.bs.carousel', { relatedTarget: relatedTarget, direction: direction }) // yes, "slid"
|
var slidEvent = $.Event('slid.bs.carousel', { relatedTarget: relatedTarget, direction: direction }) // yes, "slid"
|
||||||
|
Loading…
Reference in New Issue
Block a user