diff options
author | Mark Otto <markdotto@gmail.com> | 2016-12-05 08:05:19 +0300 |
---|---|---|
committer | Mark Otto <markdotto@gmail.com> | 2016-12-05 08:05:19 +0300 |
commit | 1e3ec8935520e2d118d9d7742abd80183d34beb2 (patch) | |
tree | 3a2e940d7d91d578db4fe86675fa9d2a11bb9512 /js/src/carousel.js | |
parent | 6782dd6e92637f85e3778584ec417a775d01243f (diff) | |
parent | 5a19d4870537ca85ba38beeb7eabe80858417b72 (diff) |
Merge branch 'v4-dev' into carousel
Diffstat (limited to 'js/src/carousel.js')
-rw-r--r-- | js/src/carousel.js | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/js/src/carousel.js b/js/src/carousel.js index c0d572f0a9..a8c16283e2 100644 --- a/js/src/carousel.js +++ b/js/src/carousel.js @@ -120,9 +120,10 @@ const Carousel = (($) => { // public next() { - if (!this._isSliding) { - this._slide(Direction.NEXT) + if (this._isSliding) { + throw new Error('Carousel is sliding') } + this._slide(Direction.NEXT) } nextWhenVisible() { @@ -133,9 +134,10 @@ const Carousel = (($) => { } prev() { - if (!this._isSliding) { - this._slide(Direction.PREVIOUS) + if (this._isSliding) { + throw new Error('Carousel is sliding') } + this._slide(Direction.PREVIOUS) } pause(event) { @@ -236,11 +238,10 @@ const Carousel = (($) => { } _keydown(event) { - event.preventDefault() - if (/input|textarea/i.test(event.target.tagName)) { return } + event.preventDefault() switch (event.which) { case ARROW_LEFT_KEYCODE: @@ -372,15 +373,10 @@ const Carousel = (($) => { $(activeElement) .one(Util.TRANSITION_END, () => { $(nextElement) - .removeClass(directionalClassName) - .removeClass(orderClassName) - - $(nextElement).addClass(ClassName.ACTIVE) + .removeClass(`${directionalClassName} ${orderClassName}`) + .addClass(ClassName.ACTIVE) - $(activeElement) - .removeClass(ClassName.ACTIVE) - .removeClass(orderClassName) - .removeClass(directionalClassName) + $(activeElement).removeClass(`${ClassName.ACTIVE} ${orderClassName} ${directionalClassName}`) this._isSliding = false |