aboutsummaryrefslogtreecommitdiff
path: root/js/src
diff options
context:
space:
mode:
Diffstat (limited to 'js/src')
-rw-r--r--js/src/carousel.js44
1 files changed, 21 insertions, 23 deletions
diff --git a/js/src/carousel.js b/js/src/carousel.js
index a5fe2597b..12102f224 100644
--- a/js/src/carousel.js
+++ b/js/src/carousel.js
@@ -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)