From: Stefan Sundin Date: Fri, 8 Aug 2014 17:11:10 +0000 (-0700) Subject: Fix bug not re-calculating scrollbar width when opening modal. X-Git-Tag: v3.3.0~197^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f25181615e0bc0e3b80e15f44bbe505842f477a4;p=thirdparty%2Fbootstrap.git Fix bug not re-calculating scrollbar width when opening modal. If opening a modal when a scrollbar is present, closing it, then resizing the window so the scrollbar disappears, then opening the modal again, the content would shift. This fixes the problem by always calculating the scrollbar width every time a modal is opened. Closes #14357. --- diff --git a/js/modal.js b/js/modal.js index f8d53e2518..38fa89edd1 100644 --- a/js/modal.js +++ b/js/modal.js @@ -207,8 +207,7 @@ } Modal.prototype.checkScrollbar = function () { - if (document.body.clientWidth >= window.innerWidth) return - this.scrollbarWidth = this.scrollbarWidth || this.measureScrollbar() + this.scrollbarWidth = this.measureScrollbar() } Modal.prototype.setScrollbar = function () { @@ -221,6 +220,7 @@ } Modal.prototype.measureScrollbar = function () { // thx walsh + if (document.body.clientWidth >= window.innerWidth) return 0 var scrollDiv = document.createElement('div') scrollDiv.className = 'modal-scrollbar-measure' this.$body.append(scrollDiv)