Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,5 @@ params:
js_hash: "sha384-nsg8ua9HAw1y0W1btsyWgBklPnCUAFLuTMS2G72MMONqmOymq585AcH49TLBQObG"
js_bundle: "https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/js/bootstrap.bundle.min.js"
js_bundle_hash: "sha384-b5kHyXgcpbZJO/tY9Ul7kGkf1S0CWuKcCD38l8YkeH8z8QjE0GmW1gYU5S9FOnJ0"
popper: "https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.0/dist/umd/popper.min.js"
popper_hash: "sha384-EOlc5FUOsy7obkrpNXqD9DtrephzQpK7DXijDIKexeJT0qfn4dZ7GDid8suWuQHq"
popper: "https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.1/dist/umd/popper.min.js"
popper_hash: "sha384-SR1sx49pcuLnqZUnnPwx6FCym0wLsk5JZuNx2bPPENzswTNFaQU1RDvt3wT4gWFG"
33 changes: 17 additions & 16 deletions js/src/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class Modal extends BaseComponent {
return
}

if (this._element.classList.contains(CLASS_NAME_FADE)) {
if (this._isAnimated()) {
this._isTransitioning = true
}

Expand Down Expand Up @@ -164,9 +164,9 @@ class Modal extends BaseComponent {
}

this._isShown = false
const transition = this._element.classList.contains(CLASS_NAME_FADE)
const isAnimated = this._isAnimated()

if (transition) {
if (isAnimated) {
this._isTransitioning = true
}

Expand All @@ -180,7 +180,7 @@ class Modal extends BaseComponent {
EventHandler.off(this._element, EVENT_CLICK_DISMISS)
EventHandler.off(this._dialog, EVENT_MOUSEDOWN_DISMISS)

if (transition) {
if (isAnimated) {
const transitionDuration = getTransitionDurationFromElement(this._element)

EventHandler.one(this._element, 'transitionend', event => this._hideModal(event))
Expand Down Expand Up @@ -229,7 +229,7 @@ class Modal extends BaseComponent {
}

_showElement(relatedTarget) {
const transition = this._element.classList.contains(CLASS_NAME_FADE)
const isAnimated = this._isAnimated()
const modalBody = SelectorEngine.findOne(SELECTOR_MODAL_BODY, this._dialog)

if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) {
Expand All @@ -247,7 +247,7 @@ class Modal extends BaseComponent {
modalBody.scrollTop = 0
}

if (transition) {
if (isAnimated) {
reflow(this._element)
}

Expand All @@ -268,7 +268,7 @@ class Modal extends BaseComponent {
})
}

if (transition) {
if (isAnimated) {
const transitionDuration = getTransitionDurationFromElement(this._dialog)

EventHandler.one(this._dialog, 'transitionend', transitionComplete)
Expand Down Expand Up @@ -332,16 +332,13 @@ class Modal extends BaseComponent {
}

_showBackdrop(callback) {
const animate = this._element.classList.contains(CLASS_NAME_FADE) ?
CLASS_NAME_FADE :
''

const isAnimated = this._isAnimated()
if (this._isShown && this._config.backdrop) {
this._backdrop = document.createElement('div')
this._backdrop.className = CLASS_NAME_BACKDROP

if (animate) {
this._backdrop.classList.add(animate)
if (isAnimated) {
this._backdrop.classList.add(CLASS_NAME_FADE)
}

document.body.appendChild(this._backdrop)
Expand All @@ -363,13 +360,13 @@ class Modal extends BaseComponent {
}
})

if (animate) {
if (isAnimated) {
reflow(this._backdrop)
}

this._backdrop.classList.add(CLASS_NAME_SHOW)

if (!animate) {
if (!isAnimated) {
callback()
return
}
Expand All @@ -386,7 +383,7 @@ class Modal extends BaseComponent {
callback()
}

if (this._element.classList.contains(CLASS_NAME_FADE)) {
if (isAnimated) {
const backdropTransitionDuration = getTransitionDurationFromElement(this._backdrop)
EventHandler.one(this._backdrop, 'transitionend', callbackRemove)
emulateTransitionEnd(this._backdrop, backdropTransitionDuration)
Expand All @@ -398,6 +395,10 @@ class Modal extends BaseComponent {
}
}

_isAnimated() {
return this._element.classList.contains(CLASS_NAME_FADE)
}

_triggerBackdropTransition() {
const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED)
if (hideEvent.defaultPrevented) {
Expand Down
Loading