aboutsummaryrefslogtreecommitdiff
path: root/js/src/modal.js
diff options
context:
space:
mode:
authorPierre Vanduynslager <[email protected]>2017-03-28 17:43:16 -0400
committerJohann-S <[email protected]>2017-03-28 23:43:15 +0200
commit48c5efa4c3c439d8720b8475ec3e372c6974a12a (patch)
tree927c262f444f4aaeb0f598cf35ab7b1b385ae76a /js/src/modal.js
parentce0e2f8e76dade4b6ec9d6eb541c6988739f0653 (diff)
downloadbootstrap-48c5efa4c3c439d8720b8475ec3e372c6974a12a.tar.xz
bootstrap-48c5efa4c3c439d8720b8475ec3e372c6974a12a.zip
Fix JS components console error "Error: <Component> is transitioning"
Diffstat (limited to 'js/src/modal.js')
-rw-r--r--js/src/modal.js19
1 files changed, 10 insertions, 9 deletions
diff --git a/js/src/modal.js b/js/src/modal.js
index 7f010b8e0..5e9941444 100644
--- a/js/src/modal.js
+++ b/js/src/modal.js
@@ -87,7 +87,6 @@ const Modal = (($) => {
this._isShown = false
this._isBodyOverflowing = false
this._ignoreBackdropClick = false
- this._isTransitioning = false
this._originalBodyPadding = 0
this._scrollbarWidth = 0
}
@@ -112,13 +111,13 @@ const Modal = (($) => {
show(relatedTarget) {
if (this._isTransitioning) {
- throw new Error('Modal is transitioning')
+ return
}
- if (Util.supportsTransitionEnd() &&
- $(this._element).hasClass(ClassName.FADE)) {
+ if (Util.supportsTransitionEnd() && $(this._element).hasClass(ClassName.FADE)) {
this._isTransitioning = true
}
+
const showEvent = $.Event(Event.SHOW, {
relatedTarget
})
@@ -161,17 +160,18 @@ const Modal = (($) => {
event.preventDefault()
}
- if (this._isTransitioning) {
- throw new Error('Modal is transitioning')
+ if (this._isTransitioning || !this._isShown) {
+ return
}
- const transition = Util.supportsTransitionEnd() &&
- $(this._element).hasClass(ClassName.FADE)
+ const transition = Util.supportsTransitionEnd() && $(this._element).hasClass(ClassName.FADE)
+
if (transition) {
this._isTransitioning = true
}
const hideEvent = $.Event(Event.HIDE)
+
$(this._element).trigger(hideEvent)
if (!this._isShown || hideEvent.isDefaultPrevented()) {
@@ -191,6 +191,7 @@ const Modal = (($) => {
$(this._dialog).off(Event.MOUSEDOWN_DISMISS)
if (transition) {
+
$(this._element)
.one(Util.TRANSITION_END, (event) => this._hideModal(event))
.emulateTransitionEnd(TRANSITION_DURATION)
@@ -307,7 +308,7 @@ const Modal = (($) => {
_hideModal() {
this._element.style.display = 'none'
- this._element.setAttribute('aria-hidden', 'true')
+ this._element.setAttribute('aria-hidden', true)
this._isTransitioning = false
this._showBackdrop(() => {
$(document.body).removeClass(ClassName.OPEN)