diff options
| author | Jacob <[email protected]> | 2014-06-11 15:19:39 -0700 |
|---|---|---|
| committer | Jacob <[email protected]> | 2014-06-11 15:19:39 -0700 |
| commit | 6ac5708a0dc8ce0c4b8f7ba47736c53d2e1bb3c6 (patch) | |
| tree | 6527363bbeb1e7ef34b813fc8e3440b457c3daef | |
| parent | 4949d26a1d3dc4b9899a6257b9bcd3be075539b0 (diff) | |
| parent | a1dad14f448b9885147a5ae05458a4c5f457b43b (diff) | |
| download | bootstrap-6ac5708a0dc8ce0c4b8f7ba47736c53d2e1bb3c6.tar.xz bootstrap-6ac5708a0dc8ce0c4b8f7ba47736c53d2e1bb3c6.zip | |
Merge pull request #13787 from twbs/fat-3731
fix #13185 - keyboard support for carousel
| -rw-r--r-- | js/carousel.js | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/js/carousel.js b/js/carousel.js index af51cf50d..bc4c60ef4 100644 --- a/js/carousel.js +++ b/js/carousel.js @@ -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 = @@ -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' @@ -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) |
