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,
getTransitionDurationFromElement,
isVisible,
isRTL,
reflow,
triggerTransitionEnd,
typeCheckConfig
@ -250,14 +251,22 @@ class Carousel extends BaseComponent {
// swipe left
if (direction > 0) {
if (isRTL) {
this.next()
} else {
this.prev()
}
}
// swipe right
if (direction < 0) {
if (isRTL) {
this.prev()
} else {
this.next()
}
}
}
_addEventListeners() {
if (this._config.keyboard) {
@ -339,12 +348,20 @@ class Carousel extends BaseComponent {
if (event.key === ARROW_LEFT_KEY) {
event.preventDefault()
if (isRTL) {
this.next()
} else {
this.prev()
}
} else if (event.key === ARROW_RIGHT_KEY) {
event.preventDefault()
if (isRTL) {
this.prev()
} else {
this.next()
}
}
}
_getItemIndex(element) {
this._items = element && element.parentNode ?