aboutsummaryrefslogtreecommitdiff
path: root/js/src/carousel.js
diff options
context:
space:
mode:
authorGeoSot <[email protected]>2021-04-11 02:27:18 +0300
committerMark Otto <[email protected]>2021-05-10 13:59:55 -0700
commit90b1a6907ed7bb3397fe6bd223f09eb12122d7a3 (patch)
treed666c155808a77ee51ab2296f549279b8f88873e /js/src/carousel.js
parent9106d2a0eaa53a58d6cf6eef7250634329578843 (diff)
downloadbootstrap-90b1a6907ed7bb3397fe6bd223f09eb12122d7a3.tar.xz
bootstrap-90b1a6907ed7bb3397fe6bd223f09eb12122d7a3.zip
Merge js-components 'transitionend' listener callbacks into one method
Diffstat (limited to 'js/src/carousel.js')
-rw-r--r--js/src/carousel.js35
1 files changed, 14 insertions, 21 deletions
diff --git a/js/src/carousel.js b/js/src/carousel.js
index 5bf7225f3..2f5cd9de9 100644
--- a/js/src/carousel.js
+++ b/js/src/carousel.js
@@ -7,9 +7,7 @@
import {
defineJQueryPlugin,
- emulateTransitionEnd,
getElementFromSelector,
- getTransitionDurationFromElement,
isRTL,
isVisible,
reflow,
@@ -454,6 +452,15 @@ class Carousel extends BaseComponent {
this._setActiveIndicatorElement(nextElement)
this._activeElement = nextElement
+ const triggerSlidEvent = () => {
+ EventHandler.trigger(this._element, EVENT_SLID, {
+ relatedTarget: nextElement,
+ direction: eventDirectionName,
+ from: activeElementIndex,
+ to: nextElementIndex
+ })
+ }
+
if (this._element.classList.contains(CLASS_NAME_SLIDE)) {
nextElement.classList.add(orderClassName)
@@ -462,9 +469,7 @@ class Carousel extends BaseComponent {
activeElement.classList.add(directionalClassName)
nextElement.classList.add(directionalClassName)
- const transitionDuration = getTransitionDurationFromElement(activeElement)
-
- EventHandler.one(activeElement, 'transitionend', () => {
+ const completeCallBack = () => {
nextElement.classList.remove(directionalClassName, orderClassName)
nextElement.classList.add(CLASS_NAME_ACTIVE)
@@ -472,28 +477,16 @@ class Carousel extends BaseComponent {
this._isSliding = false
- setTimeout(() => {
- EventHandler.trigger(this._element, EVENT_SLID, {
- relatedTarget: nextElement,
- direction: eventDirectionName,
- from: activeElementIndex,
- to: nextElementIndex
- })
- }, 0)
- })
+ setTimeout(triggerSlidEvent, 0)
+ }
- emulateTransitionEnd(activeElement, transitionDuration)
+ this._queueCallback(completeCallBack, activeElement, true)
} else {
activeElement.classList.remove(CLASS_NAME_ACTIVE)
nextElement.classList.add(CLASS_NAME_ACTIVE)
this._isSliding = false
- EventHandler.trigger(this._element, EVENT_SLID, {
- relatedTarget: nextElement,
- direction: eventDirectionName,
- from: activeElementIndex,
- to: nextElementIndex
- })
+ triggerSlidEvent()
}
if (isCycling) {