Commit 6ac5708a authored by Jacob's avatar Jacob
Browse files

Merge pull request #13787 from twbs/fat-3731

fix #13185 - keyboard support for carousel
parents 4949d26a a1dad14f
Showing with 13 additions and 3 deletions
+13 -3
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
// ========================= // =========================
var Carousel = function (element, options) { var Carousel = function (element, options) {
this.$element = $(element) this.$element = $(element).on('keydown.bs.carousel', $.proxy(this.keydown, this))
this.$indicators = this.$element.find('.carousel-indicators') this.$indicators = this.$element.find('.carousel-indicators')
this.options = options this.options = options
this.paused = this.paused =
...@@ -28,8 +28,8 @@ ...@@ -28,8 +28,8 @@
this.$items = null this.$items = null
this.options.pause == 'hover' && this.$element this.options.pause == 'hover' && this.$element
.on('mouseenter', $.proxy(this.pause, this)) .on('mouseenter.bs.carousel', $.proxy(this.pause, this))
.on('mouseleave', $.proxy(this.cycle, this)) .on('mouseleave.bs.carousel', $.proxy(this.cycle, this))
} }
Carousel.VERSION = '3.1.1' Carousel.VERSION = '3.1.1'
...@@ -40,6 +40,16 @@ ...@@ -40,6 +40,16 @@
wrap: true wrap: true
} }
Carousel.prototype.keydown = function (e) {
switch (e.which) {
case 37: this.prev(); break
case 39: this.next(); break
default: return
}
e.preventDefault()
}
Carousel.prototype.cycle = function (e) { Carousel.prototype.cycle = function (e) {
e || (this.paused = false) e || (this.paused = false)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment