Skip to content

Commit

Permalink
Merge pull request #13787 from twbs/fat-3731
Browse files Browse the repository at this point in the history
fix #13185 - keyboard support for carousel
  • Loading branch information
fat committed Jun 11, 2014
2 parents 4949d26 + a1dad14 commit 6ac5708
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions js/carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// =========================

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.options = options
this.paused =
Expand All @@ -28,8 +28,8 @@
this.$items = null

this.options.pause == 'hover' && this.$element
.on('mouseenter', $.proxy(this.pause, this))
.on('mouseleave', $.proxy(this.cycle, this))
.on('mouseenter.bs.carousel', $.proxy(this.pause, this))
.on('mouseleave.bs.carousel', $.proxy(this.cycle, this))
}

Carousel.VERSION = '3.1.1'
Expand All @@ -40,6 +40,16 @@
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) {
e || (this.paused = false)

Expand Down

0 comments on commit 6ac5708

Please sign in to comment.