Skip to content

Commit

Permalink
fix(carousel): switch prev/next directions in RTL
Browse files Browse the repository at this point in the history
  • Loading branch information
ffoodd committed Dec 14, 2020
1 parent f5001ca commit 54d0b79
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions js/src/carousel.js
Expand Up @@ -11,6 +11,7 @@ import {
getElementFromSelector,
getTransitionDurationFromElement,
isVisible,
isRTL,
reflow,
triggerTransitionEnd,
typeCheckConfig
Expand Down Expand Up @@ -250,12 +251,20 @@ class Carousel extends BaseComponent {

// swipe left
if (direction > 0) {
this.prev()
if (isRTL) {
this.next()
} else {
this.prev()
}
}

// swipe right
if (direction < 0) {
this.next()
if (isRTL) {
this.prev()
} else {
this.next()
}
}
}

Expand Down Expand Up @@ -339,10 +348,18 @@ class Carousel extends BaseComponent {

if (event.key === ARROW_LEFT_KEY) {
event.preventDefault()
this.prev()
if (isRTL) {
this.next()
} else {
this.prev()
}
} else if (event.key === ARROW_RIGHT_KEY) {
event.preventDefault()
this.next()
if (isRTL) {
this.prev()
} else {
this.next()
}
}
}

Expand Down

0 comments on commit 54d0b79

Please sign in to comment.