]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Fix bug not re-calculating scrollbar width when opening modal.
authorStefan Sundin <stefan@stefansundin.com>
Fri, 8 Aug 2014 17:11:10 +0000 (10:11 -0700)
committerChris Rebert <code@rebertia.com>
Mon, 8 Sep 2014 06:06:37 +0000 (23:06 -0700)
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.

js/modal.js

index f8d53e2518054a6ab76aa6f819ebe700c8b92c5b..38fa89edd1a1d74b3f0ea02fed585b85ba58056a 100644 (file)
   }
 
   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 () {
   }
 
   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)