aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/twbs/bootstrap/js/src/carousel.js
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2021-07-29 08:25:05 +0000
committerMario <mario@mariovavti.com>2021-07-29 08:25:05 +0000
commitd459dfac74e90c29950d49a82edc19fd913d435e (patch)
tree7bed5f2dbc318f87bbe0f4be2cde3dde09cd97c7 /vendor/twbs/bootstrap/js/src/carousel.js
parentcec2f0d894b80f3affeb60cff2d4afa49a2019a8 (diff)
downloadvolse-hubzilla-d459dfac74e90c29950d49a82edc19fd913d435e.tar.gz
volse-hubzilla-d459dfac74e90c29950d49a82edc19fd913d435e.tar.bz2
volse-hubzilla-d459dfac74e90c29950d49a82edc19fd913d435e.zip
update to bootstrap 5.0.2
Diffstat (limited to 'vendor/twbs/bootstrap/js/src/carousel.js')
-rw-r--r--vendor/twbs/bootstrap/js/src/carousel.js63
1 files changed, 23 insertions, 40 deletions
diff --git a/vendor/twbs/bootstrap/js/src/carousel.js b/vendor/twbs/bootstrap/js/src/carousel.js
index bb894e9c3..fe43f53eb 100644
--- a/vendor/twbs/bootstrap/js/src/carousel.js
+++ b/vendor/twbs/bootstrap/js/src/carousel.js
@@ -1,6 +1,6 @@
/**
* --------------------------------------------------------------------------
- * Bootstrap (v5.0.1): carousel.js
+ * Bootstrap (v5.0.2): carousel.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
@@ -10,11 +10,11 @@ import {
getElementFromSelector,
isRTL,
isVisible,
+ getNextActiveElement,
reflow,
triggerTransitionEnd,
typeCheckConfig
} from './util/index'
-import Data from './dom/data'
import EventHandler from './dom/event-handler'
import Manipulator from './dom/manipulator'
import SelectorEngine from './dom/selector-engine'
@@ -59,6 +59,11 @@ const ORDER_PREV = 'prev'
const DIRECTION_LEFT = 'left'
const DIRECTION_RIGHT = 'right'
+const KEY_TO_DIRECTION = {
+ [ARROW_LEFT_KEY]: DIRECTION_RIGHT,
+ [ARROW_RIGHT_KEY]: DIRECTION_LEFT
+}
+
const EVENT_SLIDE = `slide${EVENT_KEY}`
const EVENT_SLID = `slid${EVENT_KEY}`
const EVENT_KEYDOWN = `keydown${EVENT_KEY}`
@@ -134,9 +139,7 @@ class Carousel extends BaseComponent {
// Public
next() {
- if (!this._isSliding) {
- this._slide(ORDER_NEXT)
- }
+ this._slide(ORDER_NEXT)
}
nextWhenVisible() {
@@ -148,9 +151,7 @@ class Carousel extends BaseComponent {
}
prev() {
- if (!this._isSliding) {
- this._slide(ORDER_PREV)
- }
+ this._slide(ORDER_PREV)
}
pause(event) {
@@ -218,7 +219,8 @@ class Carousel extends BaseComponent {
_getConfig(config) {
config = {
...Default,
- ...config
+ ...Manipulator.getDataAttributes(this._element),
+ ...(typeof config === 'object' ? config : {})
}
typeCheckConfig(NAME, config, DefaultType)
return config
@@ -318,12 +320,10 @@ class Carousel extends BaseComponent {
return
}
- if (event.key === ARROW_LEFT_KEY) {
- event.preventDefault()
- this._slide(DIRECTION_RIGHT)
- } else if (event.key === ARROW_RIGHT_KEY) {
+ const direction = KEY_TO_DIRECTION[event.key]
+ if (direction) {
event.preventDefault()
- this._slide(DIRECTION_LEFT)
+ this._slide(direction)
}
}
@@ -337,21 +337,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) {
@@ -421,6 +407,10 @@ class Carousel extends BaseComponent {
return
}
+ if (this._isSliding) {
+ return
+ }
+
const slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName)
if (slideEvent.defaultPrevented) {
return
@@ -509,12 +499,9 @@ class Carousel extends BaseComponent {
// Static
static carouselInterface(element, config) {
- let data = Data.get(element, DATA_KEY)
- let _config = {
- ...Default,
- ...Manipulator.getDataAttributes(element)
- }
+ const data = Carousel.getOrCreateInstance(element, config)
+ let { _config } = data
if (typeof config === 'object') {
_config = {
..._config,
@@ -524,10 +511,6 @@ class Carousel extends BaseComponent {
const action = typeof config === 'string' ? config : _config.slide
- if (!data) {
- data = new Carousel(element, _config)
- }
-
if (typeof config === 'number') {
data.to(config)
} else if (typeof action === 'string') {
@@ -568,7 +551,7 @@ class Carousel extends BaseComponent {
Carousel.carouselInterface(target, config)
if (slideIndex) {
- Data.get(target, DATA_KEY).to(slideIndex)
+ Carousel.getInstance(target).to(slideIndex)
}
event.preventDefault()
@@ -587,7 +570,7 @@ EventHandler.on(window, EVENT_LOAD_DATA_API, () => {
const carousels = SelectorEngine.find(SELECTOR_DATA_RIDE)
for (let i = 0, len = carousels.length; i < len; i++) {
- Carousel.carouselInterface(carousels[i], Data.get(carousels[i], DATA_KEY))
+ Carousel.carouselInterface(carousels[i], Carousel.getInstance(carousels[i]))
}
})