]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
fix(carousel): switch prev/next directions in RTL
authorGaël Poupard <gael.poupard@orange.com>
Fri, 11 Dec 2020 14:10:58 +0000 (15:10 +0100)
committerXhmikosR <xhmikosr@gmail.com>
Mon, 14 Dec 2020 09:11:47 +0000 (11:11 +0200)
js/src/carousel.js

index a266ec10f9ee5414fcb09b541ab78ea3072092bc..06a391419f0cd6ac68bee33bfd9edb57fe0d1137 100644 (file)
@@ -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()
+      }
     }
   }