0
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-01-19 11:52:21 +01:00

fix(carousel): switch prev/next directions in RTL

This commit is contained in:
Gaël Poupard 2020-12-11 15:10:58 +01:00 committed by XhmikosR
parent e967ecf900
commit b85ca045e0

View File

@ -11,6 +11,7 @@ import {
getElementFromSelector, getElementFromSelector,
getTransitionDurationFromElement, getTransitionDurationFromElement,
isVisible, isVisible,
isRTL,
reflow, reflow,
triggerTransitionEnd, triggerTransitionEnd,
typeCheckConfig typeCheckConfig
@ -250,12 +251,20 @@ class Carousel extends BaseComponent {
// swipe left // swipe left
if (direction > 0) { if (direction > 0) {
this.prev() if (isRTL) {
this.next()
} else {
this.prev()
}
} }
// swipe right // swipe right
if (direction < 0) { if (direction < 0) {
this.next() if (isRTL) {
this.prev()
} else {
this.next()
}
} }
} }
@ -339,10 +348,18 @@ class Carousel extends BaseComponent {
if (event.key === ARROW_LEFT_KEY) { if (event.key === ARROW_LEFT_KEY) {
event.preventDefault() event.preventDefault()
this.prev() if (isRTL) {
this.next()
} else {
this.prev()
}
} else if (event.key === ARROW_RIGHT_KEY) { } else if (event.key === ARROW_RIGHT_KEY) {
event.preventDefault() event.preventDefault()
this.next() if (isRTL) {
this.prev()
} else {
this.next()
}
} }
} }