return
}
- if (this._element.classList.contains(CLASS_NAME_FADE)) {
+ if (this._isAnimated()) {
this._isTransitioning = true
}
}
this._isShown = false
- const transition = this._element.classList.contains(CLASS_NAME_FADE)
+ const isAnimated = this._isAnimated()
- if (transition) {
+ if (isAnimated) {
this._isTransitioning = true
}
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))
}
_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) {
modalBody.scrollTop = 0
}
- if (transition) {
+ if (isAnimated) {
reflow(this._element)
}
})
}
- if (transition) {
+ if (isAnimated) {
const transitionDuration = getTransitionDurationFromElement(this._dialog)
EventHandler.one(this._dialog, 'transitionend', transitionComplete)
}
_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)
}
})
- if (animate) {
+ if (isAnimated) {
reflow(this._backdrop)
}
this._backdrop.classList.add(CLASS_NAME_SHOW)
- if (!animate) {
+ if (!isAnimated) {
callback()
return
}
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)
}
}
+ _isAnimated() {
+ return this._element.classList.contains(CLASS_NAME_FADE)
+ }
+
_triggerBackdropTransition() {
const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED)
if (hideEvent.defaultPrevented) {