mirror of
https://github.com/twbs/bootstrap.git
synced 2022-11-09 12:25:43 -05:00
add slide and slid events + disable sliding during slide
This commit is contained in:
parent
fbd686ad65
commit
f83240a8f9
1 changed files with 10 additions and 0 deletions
10
js/bootstrap-carousel.js
vendored
10
js/bootstrap-carousel.js
vendored
|
@ -44,10 +44,12 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
, next: function () {
|
, next: function () {
|
||||||
|
if (this.sliding) return
|
||||||
return this.slide('next')
|
return this.slide('next')
|
||||||
}
|
}
|
||||||
|
|
||||||
, prev: function () {
|
, prev: function () {
|
||||||
|
if (this.sliding) return
|
||||||
return this.slide('prev')
|
return this.slide('prev')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,21 +61,29 @@
|
||||||
, fallback = type == 'next' ? 'first' : 'last'
|
, fallback = type == 'next' ? 'first' : 'last'
|
||||||
, that = this
|
, that = this
|
||||||
|
|
||||||
|
this.sliding = true
|
||||||
|
|
||||||
isCycling && this.pause()
|
isCycling && this.pause()
|
||||||
|
|
||||||
$next = $next.length ? $next : this.$element.find('.item')[fallback]()
|
$next = $next.length ? $next : this.$element.find('.item')[fallback]()
|
||||||
|
|
||||||
if (!$.support.transition && this.$element.hasClass('slide')) {
|
if (!$.support.transition && this.$element.hasClass('slide')) {
|
||||||
|
this.$element.trigger('slide')
|
||||||
$active.removeClass('active')
|
$active.removeClass('active')
|
||||||
$next.addClass('active')
|
$next.addClass('active')
|
||||||
|
this.$element.trigger('slid')
|
||||||
|
this.sliding = false
|
||||||
} else {
|
} else {
|
||||||
$next.addClass(type)
|
$next.addClass(type)
|
||||||
$next[0].offsetWidth // force reflow
|
$next[0].offsetWidth // force reflow
|
||||||
$active.addClass(direction)
|
$active.addClass(direction)
|
||||||
$next.addClass(direction)
|
$next.addClass(direction)
|
||||||
|
this.$element.trigger('slide')
|
||||||
this.$element.one($.support.transition.end, function () {
|
this.$element.one($.support.transition.end, function () {
|
||||||
$next.removeClass([type, direction].join(' ')).addClass('active')
|
$next.removeClass([type, direction].join(' ')).addClass('active')
|
||||||
$active.removeClass(['active', direction].join(' '))
|
$active.removeClass(['active', direction].join(' '))
|
||||||
|
that.$element.trigger('slid')
|
||||||
|
that.sliding = false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue