diff options
| author | Mark Otto <[email protected]> | 2016-12-02 10:13:36 -0800 |
|---|---|---|
| committer | Mark Otto <[email protected]> | 2016-12-02 10:13:36 -0800 |
| commit | 3ec37d4a4d043ded903c807818e7894de084409f (patch) | |
| tree | aaf483f062a7f721093632df5d0d198e9830dacc /js/dist/modal.js | |
| parent | e3a569f4f6ab326d78300c6a8ab3e3766075cfd0 (diff) | |
| download | bootstrap-3ec37d4a4d043ded903c807818e7894de084409f.tar.xz bootstrap-3ec37d4a4d043ded903c807818e7894de084409f.zip | |
grunt
Diffstat (limited to 'js/dist/modal.js')
| -rw-r--r-- | js/dist/modal.js | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/js/dist/modal.js b/js/dist/modal.js index 68880ad58..d9797567c 100644 --- a/js/dist/modal.js +++ b/js/dist/modal.js @@ -89,6 +89,7 @@ var Modal = function ($) { this._isShown = false; this._isBodyOverflowing = false; this._ignoreBackdropClick = false; + this._isTransitioning = false; this._originalBodyPadding = 0; this._scrollbarWidth = 0; } @@ -104,6 +105,13 @@ var Modal = function ($) { Modal.prototype.show = function show(relatedTarget) { var _this = this; + if (this._isTransitioning) { + throw new Error('Modal is transitioning'); + } + + if (Util.supportsTransitionEnd() && $(this._element).hasClass(ClassName.FADE)) { + this._isTransitioning = true; + } var showEvent = $.Event(Event.SHOW, { relatedTarget: relatedTarget }); @@ -148,8 +156,16 @@ var Modal = function ($) { event.preventDefault(); } - var hideEvent = $.Event(Event.HIDE); + if (this._isTransitioning) { + throw new Error('Modal is transitioning'); + } + + var transition = Util.supportsTransitionEnd() && $(this._element).hasClass(ClassName.FADE); + if (transition) { + this._isTransitioning = true; + } + var hideEvent = $.Event(Event.HIDE); $(this._element).trigger(hideEvent); if (!this._isShown || hideEvent.isDefaultPrevented()) { @@ -168,8 +184,7 @@ var Modal = function ($) { $(this._element).off(Event.CLICK_DISMISS); $(this._dialog).off(Event.MOUSEDOWN_DISMISS); - if (Util.supportsTransitionEnd() && $(this._element).hasClass(ClassName.FADE)) { - + if (transition) { $(this._element).one(Util.TRANSITION_END, function (event) { return _this2._hideModal(event); }).emulateTransitionEnd(TRANSITION_DURATION); @@ -234,6 +249,7 @@ var Modal = function ($) { if (_this3._config.focus) { _this3._element.focus(); } + _this3._isTransitioning = false; $(_this3._element).trigger(shownEvent); }; @@ -285,7 +301,8 @@ var Modal = function ($) { var _this7 = this; this._element.style.display = 'none'; - this._element.setAttribute('aria-hidden', true); + this._element.setAttribute('aria-hidden', 'true'); + this._isTransitioning = false; this._showBackdrop(function () { $(document.body).removeClass(ClassName.OPEN); _this7._resetAdjustments(); |
