diff options
| author | GeoSot <[email protected]> | 2021-05-19 01:23:52 +0300 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-05-19 01:23:52 +0300 |
| commit | df72a21fa89a4885bb666f4a3bc0a9e757b870c2 (patch) | |
| tree | d80c2614184e53f73de9364ac46dbeef9f61aa08 /js/src/carousel.js | |
| parent | 372890b67b28238c98ec4d5ffcdb777c9939e87c (diff) | |
| download | bootstrap-df72a21fa89a4885bb666f4a3bc0a9e757b870c2.tar.xz bootstrap-df72a21fa89a4885bb666f4a3bc0a9e757b870c2.zip | |
Add `getNextActiveElement` helper function to utils, replacing custom implementation through components (#33608)
Diffstat (limited to 'js/src/carousel.js')
| -rw-r--r-- | js/src/carousel.js | 17 |
1 files changed, 2 insertions, 15 deletions
diff --git a/js/src/carousel.js b/js/src/carousel.js index bb894e9c3..7d197ab1e 100644 --- a/js/src/carousel.js +++ b/js/src/carousel.js @@ -10,6 +10,7 @@ import { getElementFromSelector, isRTL, isVisible, + getNextActiveElement, reflow, triggerTransitionEnd, typeCheckConfig @@ -337,21 +338,7 @@ class Carousel extends BaseComponent { _getItemByOrder(order, activeElement) { const isNext = order === ORDER_NEXT - const isPrev = order === ORDER_PREV - const activeIndex = this._getItemIndex(activeElement) - const lastItemIndex = this._items.length - 1 - const isGoingToWrap = (isPrev && activeIndex === 0) || (isNext && activeIndex === lastItemIndex) - - if (isGoingToWrap && !this._config.wrap) { - return activeElement - } - - const delta = isPrev ? -1 : 1 - const itemIndex = (activeIndex + delta) % this._items.length - - return itemIndex === -1 ? - this._items[this._items.length - 1] : - this._items[itemIndex] + return getNextActiveElement(this._items, activeElement, isNext, this._config.wrap) } _triggerSlideEvent(relatedTarget, eventDirectionName) { |
