mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-09 15:16:51 +02:00
fix(carousel): switch prev/next directions in RTL
This commit is contained in:
@@ -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 ?
|
||||
|
Reference in New Issue
Block a user