]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Carousel: move logic of `dataApiClickHandler`
authorGeoSot <geo.sotis@gmail.com>
Sat, 19 Feb 2022 17:02:51 +0000 (19:02 +0200)
committerXhmikosR <xhmikosr@gmail.com>
Tue, 1 Mar 2022 14:56:33 +0000 (16:56 +0200)
js/src/carousel.js

index a5fe2597b8e46a68748d421f257857d3e63aee31..12102f2246ee8feda8247785d098a6239cc5f7c8 100644 (file)
@@ -464,38 +464,36 @@ class Carousel extends BaseComponent {
       Carousel.carouselInterface(this, config)
     })
   }
+}
 
-  static dataApiClickHandler(event) {
-    const target = getElementFromSelector(this)
-
-    if (!target || !target.classList.contains(CLASS_NAME_CAROUSEL)) {
-      return
-    }
+/**
+ * Data API implementation
+ */
 
-    event.preventDefault()
+EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_SLIDE, function (event) {
+  const target = getElementFromSelector(this)
 
-    const carousel = Carousel.getOrCreateInstance(target)
-    const slideIndex = this.getAttribute('data-bs-slide-to')
+  if (!target || !target.classList.contains(CLASS_NAME_CAROUSEL)) {
+    return
+  }
 
-    if (slideIndex) {
-      carousel.to(slideIndex)
-      return
-    }
+  event.preventDefault()
 
-    if (Manipulator.getDataAttribute(this, 'slide') === 'next') {
-      carousel.next()
-      return
-    }
+  const carousel = Carousel.getOrCreateInstance(target)
+  const slideIndex = this.getAttribute('data-bs-slide-to')
 
-    carousel.prev()
+  if (slideIndex) {
+    carousel.to(slideIndex)
+    return
   }
-}
 
-/**
- * Data API implementation
- */
+  if (Manipulator.getDataAttribute(this, 'slide') === 'next') {
+    carousel.next()
+    return
+  }
 
-EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_SLIDE, Carousel.dataApiClickHandler)
+  carousel.prev()
+})
 
 EventHandler.on(window, EVENT_LOAD_DATA_API, () => {
   const carousels = SelectorEngine.find(SELECTOR_DATA_RIDE)