mirror of
https://github.com/twbs/bootstrap.git
synced 2025-09-26 05:19:15 +02:00
Add getNextActiveElement
helper function to utils, replacing custom implementation through components (#33608)
This commit is contained in:
@@ -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) {
|
||||
|
Reference in New Issue
Block a user