From: Roland Warmerdam Date: Sat, 31 Aug 2013 06:03:09 +0000 (+1200) Subject: carousel: correctly reset when the slide event is prevented X-Git-Tag: v3.1.0~136^2~29^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ed1bd2b150dd645c11f92126a12183985ddbbc15;p=thirdparty%2Fbootstrap.git carousel: correctly reset when the slide event is prevented --- diff --git a/js/carousel.js b/js/carousel.js index d8c4c243ca..08d53b893d 100644 --- a/js/carousel.js +++ b/js/carousel.js @@ -111,13 +111,15 @@ $next = this.$element.find('.item')[fallback]() } - this.sliding = true - - isCycling && this.pause() + if ($next.hasClass('active')) return var e = $.Event('slide.bs.carousel', { relatedTarget: $next[0], direction: direction }) + this.$element.trigger(e) + if (e.isDefaultPrevented()) return - if ($next.hasClass('active')) return + this.sliding = true + + isCycling && this.pause() if (this.$indicators.length) { this.$indicators.find('.active').removeClass('active') @@ -128,8 +130,6 @@ } if ($.support.transition && this.$element.hasClass('slide')) { - this.$element.trigger(e) - if (e.isDefaultPrevented()) return $next.addClass(type) $next[0].offsetWidth // force reflow $active.addClass(direction) @@ -143,8 +143,6 @@ }) .emulateTransitionEnd(600) } else { - this.$element.trigger(e) - if (e.isDefaultPrevented()) return $active.removeClass('active') $next.addClass('active') this.sliding = false diff --git a/js/tests/unit/carousel.js b/js/tests/unit/carousel.js index badf0886d3..e1e34afaf6 100644 --- a/js/tests/unit/carousel.js +++ b/js/tests/unit/carousel.js @@ -16,7 +16,7 @@ $(function () { ok($(document.body).carousel()[0] == document.body, 'document.body returned') }) - test("should not fire sliden when slide is prevented", function () { + test("should not fire slid when slide is prevented", function () { $.support.transition = false stop() $('