aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorGaĆ«l Poupard <[email protected]>2020-12-11 15:10:58 +0100
committerXhmikosR <[email protected]>2020-12-14 11:11:47 +0200
commitb85ca045e057d6f5982cc0cc9de4bfbf8b252a3d (patch)
tree0593456ce2fa309cf06bc6028e6dbe9a9726831b /js
parente967ecf90021b9666bc5184f9054e7d37f9d83f4 (diff)
downloadbootstrap-b85ca045e057d6f5982cc0cc9de4bfbf8b252a3d.tar.xz
bootstrap-b85ca045e057d6f5982cc0cc9de4bfbf8b252a3d.zip
fix(carousel): switch prev/next directions in RTL
Diffstat (limited to 'js')
-rw-r--r--js/src/carousel.js25
1 files changed, 21 insertions, 4 deletions
diff --git a/js/src/carousel.js b/js/src/carousel.js
index a266ec10f..06a391419 100644
--- a/js/src/carousel.js
+++ b/js/src/carousel.js
@@ -11,6 +11,7 @@ import {
getElementFromSelector,
getTransitionDurationFromElement,
isVisible,
+ isRTL,
reflow,
triggerTransitionEnd,
typeCheckConfig
@@ -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()
+ }
}
}
@@ -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()
+ }
}
}