Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeoSot <geo.sotis@gmail.com>2022-02-19 20:02:51 +0300
committerXhmikosR <xhmikosr@gmail.com>2022-03-01 17:56:33 +0300
commit13042d25cae2a8f5d43e24cd143cb1303aaed41e (patch)
treee0eed811f3586bc1b3ea5f39a64097017baca153
parent631cec4f70fa74b066c9d949aa5b8bf8cf06b46d (diff)
Carousel: move logic of `dataApiClickHandler`
-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 a5fe2597b8..12102f2246 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)