diff options
author | Gleb Mazovetskiy <glex.spb@gmail.com> | 2014-08-12 05:12:06 +0400 |
---|---|---|
committer | Gleb Mazovetskiy <glex.spb@gmail.com> | 2014-08-12 05:12:06 +0400 |
commit | 6d6a7fe36b87799af8c0e719bef7e3b6b04d11ca (patch) | |
tree | 2d64b6d9395367d59b9f5d1e252f0e21ce03c7c1 /assets/javascripts/bootstrap/carousel.js | |
parent | fb8dad665bdd4d1a43d4049b8fdde4e1b9c529f7 (diff) |
rake convert
Diffstat (limited to 'assets/javascripts/bootstrap/carousel.js')
-rw-r--r-- | assets/javascripts/bootstrap/carousel.js | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/assets/javascripts/bootstrap/carousel.js b/assets/javascripts/bootstrap/carousel.js index b7da1ba..65cc7b9 100644 --- a/assets/javascripts/bootstrap/carousel.js +++ b/assets/javascripts/bootstrap/carousel.js @@ -30,6 +30,8 @@ Carousel.VERSION = '3.2.0' + Carousel.TRANSITION_DURATION = 600 + Carousel.DEFAULTS = { interval: 5000, pause: 'hover', @@ -63,6 +65,13 @@ return this.$items.index(item || this.$active) } + Carousel.prototype.getItemForDirection = function (direction, active) { + var delta = direction == 'prev' ? -1 : 1 + var activeIndex = this.getItemIndex(active) + var itemIndex = (activeIndex + delta) % this.$items.length + return this.$items.eq(itemIndex) + } + Carousel.prototype.to = function (pos) { var that = this var activeIndex = this.getItemIndex(this.$active = this.$element.find('.item.active')) @@ -72,7 +81,7 @@ if (this.sliding) return this.$element.one('slid.bs.carousel', function () { that.to(pos) }) // yes, "slid" if (activeIndex == pos) return this.pause().cycle() - return this.slide(pos > activeIndex ? 'next' : 'prev', $(this.$items[pos])) + return this.slide(pos > activeIndex ? 'next' : 'prev', this.$items.eq(pos)) } Carousel.prototype.pause = function (e) { @@ -100,7 +109,7 @@ Carousel.prototype.slide = function (type, next) { var $active = this.$element.find('.item.active') - var $next = next || $active[type]() + var $next = next || this.getItemForDirection(type, $active) var isCycling = this.interval var direction = type == 'next' ? 'left' : 'right' var fallback = type == 'next' ? 'first' : 'last' @@ -146,7 +155,7 @@ that.$element.trigger(slidEvent) }, 0) }) - .emulateTransitionEnd($active.css('transition-duration').slice(0, -1) * 1000) + .emulateTransitionEnd(Carousel.TRANSITION_DURATION) } else { $active.removeClass('active') $next.addClass('active') |