mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-13 17:14:04 +02:00
pull in js changes from #18830
This commit is contained in:
@@ -45,7 +45,9 @@ const Carousel = (($) => {
|
|||||||
|
|
||||||
const Direction = {
|
const Direction = {
|
||||||
NEXT : 'next',
|
NEXT : 'next',
|
||||||
PREVIOUS : 'prev'
|
PREVIOUS : 'prev',
|
||||||
|
LEFT : 'left',
|
||||||
|
RIGHT : 'right'
|
||||||
}
|
}
|
||||||
|
|
||||||
const Event = {
|
const Event = {
|
||||||
@@ -62,8 +64,10 @@ const Carousel = (($) => {
|
|||||||
CAROUSEL : 'carousel',
|
CAROUSEL : 'carousel',
|
||||||
ACTIVE : 'active',
|
ACTIVE : 'active',
|
||||||
SLIDE : 'slide',
|
SLIDE : 'slide',
|
||||||
RIGHT : 'right',
|
RIGHT : 'carousel-item-right',
|
||||||
LEFT : 'left',
|
LEFT : 'carousel-item-left',
|
||||||
|
NEXT : 'carousel-item-next',
|
||||||
|
PREVIOUS : 'carousel-item-prev',
|
||||||
ITEM : 'carousel-item'
|
ITEM : 'carousel-item'
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,7 +75,7 @@ const Carousel = (($) => {
|
|||||||
ACTIVE : '.active',
|
ACTIVE : '.active',
|
||||||
ACTIVE_ITEM : '.active.carousel-item',
|
ACTIVE_ITEM : '.active.carousel-item',
|
||||||
ITEM : '.carousel-item',
|
ITEM : '.carousel-item',
|
||||||
NEXT_PREV : '.next, .prev',
|
NEXT_PREV : '.carousel-item-next, .carousel-item-prev',
|
||||||
INDICATORS : '.carousel-indicators',
|
INDICATORS : '.carousel-indicators',
|
||||||
DATA_SLIDE : '[data-slide], [data-slide-to]',
|
DATA_SLIDE : '[data-slide], [data-slide-to]',
|
||||||
DATA_RIDE : '[data-ride="carousel"]'
|
DATA_RIDE : '[data-ride="carousel"]'
|
||||||
@@ -275,10 +279,10 @@ const Carousel = (($) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_triggerSlideEvent(relatedTarget, directionalClassname) {
|
_triggerSlideEvent(relatedTarget, eventDirectionName) {
|
||||||
const slideEvent = $.Event(Event.SLIDE, {
|
const slideEvent = $.Event(Event.SLIDE, {
|
||||||
relatedTarget,
|
relatedTarget,
|
||||||
direction: directionalClassname
|
direction: eventDirectionName
|
||||||
})
|
})
|
||||||
|
|
||||||
$(this._element).trigger(slideEvent)
|
$(this._element).trigger(slideEvent)
|
||||||
@@ -309,16 +313,30 @@ const Carousel = (($) => {
|
|||||||
|
|
||||||
const isCycling = Boolean(this._interval)
|
const isCycling = Boolean(this._interval)
|
||||||
|
|
||||||
const directionalClassName = direction === Direction.NEXT ?
|
let directionalClassName
|
||||||
ClassName.LEFT :
|
let orderClassName
|
||||||
ClassName.RIGHT
|
let eventDirectionName
|
||||||
|
|
||||||
|
if (direction === Direction.NEXT) {
|
||||||
|
directionalClassName = ClassName.LEFT
|
||||||
|
orderClassName = ClassName.NEXT
|
||||||
|
eventDirectionName = Direction.LEFT
|
||||||
|
} else {
|
||||||
|
directionalClassName = ClassName.RIGHT
|
||||||
|
orderClassName = ClassName.PREV
|
||||||
|
eventDirectionName = Direction.RIGHT
|
||||||
|
}
|
||||||
|
|
||||||
|
// const directionalClassName = direction === Direction.NEXT ?
|
||||||
|
// ClassName.LEFT :
|
||||||
|
// ClassName.RIGHT
|
||||||
|
|
||||||
if (nextElement && $(nextElement).hasClass(ClassName.ACTIVE)) {
|
if (nextElement && $(nextElement).hasClass(ClassName.ACTIVE)) {
|
||||||
this._isSliding = false
|
this._isSliding = false
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const slideEvent = this._triggerSlideEvent(nextElement, directionalClassName)
|
const slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName)
|
||||||
if (slideEvent.isDefaultPrevented()) {
|
if (slideEvent.isDefaultPrevented()) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -338,13 +356,13 @@ const Carousel = (($) => {
|
|||||||
|
|
||||||
const slidEvent = $.Event(Event.SLID, {
|
const slidEvent = $.Event(Event.SLID, {
|
||||||
relatedTarget: nextElement,
|
relatedTarget: nextElement,
|
||||||
direction: directionalClassName
|
direction: eventDirectionName
|
||||||
})
|
})
|
||||||
|
|
||||||
if (Util.supportsTransitionEnd() &&
|
if (Util.supportsTransitionEnd() &&
|
||||||
$(this._element).hasClass(ClassName.SLIDE)) {
|
$(this._element).hasClass(ClassName.SLIDE)) {
|
||||||
|
|
||||||
$(nextElement).addClass(direction)
|
$(nextElement).addClass(orderClassName)
|
||||||
|
|
||||||
Util.reflow(nextElement)
|
Util.reflow(nextElement)
|
||||||
|
|
||||||
@@ -355,13 +373,13 @@ const Carousel = (($) => {
|
|||||||
.one(Util.TRANSITION_END, () => {
|
.one(Util.TRANSITION_END, () => {
|
||||||
$(nextElement)
|
$(nextElement)
|
||||||
.removeClass(directionalClassName)
|
.removeClass(directionalClassName)
|
||||||
.removeClass(direction)
|
.removeClass(orderClassName)
|
||||||
|
|
||||||
$(nextElement).addClass(ClassName.ACTIVE)
|
$(nextElement).addClass(ClassName.ACTIVE)
|
||||||
|
|
||||||
$(activeElement)
|
$(activeElement)
|
||||||
.removeClass(ClassName.ACTIVE)
|
.removeClass(ClassName.ACTIVE)
|
||||||
.removeClass(direction)
|
.removeClass(orderClassName)
|
||||||
.removeClass(directionalClassName)
|
.removeClass(directionalClassName)
|
||||||
|
|
||||||
this._isSliding = false
|
this._isSliding = false
|
||||||
|
Reference in New Issue
Block a user