]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Carousel: refactor dataApiKeyHandler to avoid use of `carouselInterface`
authorGeoSot <geo.sotis@gmail.com>
Fri, 10 Sep 2021 00:33:14 +0000 (03:33 +0300)
committerXhmikosR <xhmikosr@gmail.com>
Tue, 1 Mar 2022 14:56:33 +0000 (16:56 +0200)
js/src/carousel.js

index 7b22e9cbfed095fa3938f8020f67eb15333fe5d8..a5fe2597b8e46a68748d421f257857d3e63aee31 100644 (file)
@@ -472,22 +472,22 @@ class Carousel extends BaseComponent {
       return
     }
 
-    const config = {
-      ...Manipulator.getDataAttributes(this)
-    }
+    event.preventDefault()
+
+    const carousel = Carousel.getOrCreateInstance(target)
     const slideIndex = this.getAttribute('data-bs-slide-to')
 
     if (slideIndex) {
-      config.interval = false
+      carousel.to(slideIndex)
+      return
     }
 
-    Carousel.carouselInterface(target, config)
-
-    if (slideIndex) {
-      Carousel.getInstance(target).to(slideIndex)
+    if (Manipulator.getDataAttribute(this, 'slide') === 'next') {
+      carousel.next()
+      return
     }
 
-    event.preventDefault()
+    carousel.prev()
   }
 }