aboutsummaryrefslogtreecommitdiff
path: root/js/src/carousel.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/carousel.js')
-rw-r--r--js/src/carousel.js17
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) {