aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Thornton <[email protected]>2012-01-08 13:39:27 -0800
committerJacob Thornton <[email protected]>2012-01-08 13:39:27 -0800
commitf83240a8f93349c93582a96c4f4a7541388d6a80 (patch)
treefe1787006667ad4779f82db7f04527ed2d6a384f
parentfbd686ad655e1a22450f517e9ec241eaafc167f7 (diff)
downloadbootstrap-f83240a8f93349c93582a96c4f4a7541388d6a80.tar.xz
bootstrap-f83240a8f93349c93582a96c4f4a7541388d6a80.zip
add slide and slid events + disable sliding during slide
-rw-r--r--js/bootstrap-carousel.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/js/bootstrap-carousel.js b/js/bootstrap-carousel.js
index fa5247c97..c49f89ad8 100644
--- a/js/bootstrap-carousel.js
+++ b/js/bootstrap-carousel.js
@@ -44,10 +44,12 @@
}
, next: function () {
+ if (this.sliding) return
return this.slide('next')
}
, prev: function () {
+ if (this.sliding) return
return this.slide('prev')
}
@@ -59,21 +61,29 @@
, fallback = type == 'next' ? 'first' : 'last'
, that = this
+ this.sliding = true
+
isCycling && this.pause()
$next = $next.length ? $next : this.$element.find('.item')[fallback]()
if (!$.support.transition && this.$element.hasClass('slide')) {
+ this.$element.trigger('slide')
$active.removeClass('active')
$next.addClass('active')
+ this.$element.trigger('slid')
+ this.sliding = false
} else {
$next.addClass(type)
$next[0].offsetWidth // force reflow
$active.addClass(direction)
$next.addClass(direction)
+ this.$element.trigger('slide')
this.$element.one($.support.transition.end, function () {
$next.removeClass([type, direction].join(' ')).addClass('active')
$active.removeClass(['active', direction].join(' '))
+ that.$element.trigger('slid')
+ that.sliding = false
})
}