Commit 09072442 authored by Tyler Cipriani's avatar Tyler Cipriani Committed by Chris Rebert
Browse files

Modal body shift fix for IE10/11

Closes #13103 by merging it.
parent 28e6c342
Showing with 30 additions and 20 deletions
+30 -20
...@@ -795,11 +795,12 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re ...@@ -795,11 +795,12 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
// ====================== // ======================
var Modal = function (element, options) { var Modal = function (element, options) {
this.options = options this.options = options
this.$body = $(document.body) this.$body = $(document.body)
this.$element = $(element) this.$element = $(element)
this.$backdrop = this.$backdrop =
this.isShown = null this.isShown = null
this.scrollbarWidth = 0
if (this.options.remote) { if (this.options.remote) {
this.$element this.$element
...@@ -830,6 +831,7 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re ...@@ -830,6 +831,7 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
this.isShown = true this.isShown = true
this.checkScrollbar()
this.$body.addClass('modal-open') this.$body.addClass('modal-open')
this.setScrollbar() this.setScrollbar()
...@@ -976,11 +978,14 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re ...@@ -976,11 +978,14 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
} }
} }
Modal.prototype.checkScrollbar = function () {
if (document.body.clientWidth >= window.innerWidth) return
this.scrollbarWidth = this.scrollbarWidth || this.measureScrollbar()
}
Modal.prototype.setScrollbar = function () { Modal.prototype.setScrollbar = function () {
if (document.body.clientHeight <= window.innerHeight) return var bodyPad = parseInt(this.$body.css('padding-right') || 0)
var scrollbarWidth = this.measureScrollbar() if (this.scrollbarWidth) this.$body.css('padding-right', bodyPad + this.scrollbarWidth)
var bodyPad = parseInt(this.$body.css('padding-right') || 0)
if (scrollbarWidth) this.$body.css('padding-right', bodyPad + scrollbarWidth)
} }
Modal.prototype.resetScrollbar = function () { Modal.prototype.resetScrollbar = function () {
......
This diff is collapsed.
This diff is collapsed.
...@@ -14,11 +14,12 @@ ...@@ -14,11 +14,12 @@
// ====================== // ======================
var Modal = function (element, options) { var Modal = function (element, options) {
this.options = options this.options = options
this.$body = $(document.body) this.$body = $(document.body)
this.$element = $(element) this.$element = $(element)
this.$backdrop = this.$backdrop =
this.isShown = null this.isShown = null
this.scrollbarWidth = 0
if (this.options.remote) { if (this.options.remote) {
this.$element this.$element
...@@ -49,6 +50,7 @@ ...@@ -49,6 +50,7 @@
this.isShown = true this.isShown = true
this.checkScrollbar()
this.$body.addClass('modal-open') this.$body.addClass('modal-open')
this.setScrollbar() this.setScrollbar()
...@@ -195,11 +197,14 @@ ...@@ -195,11 +197,14 @@
} }
} }
Modal.prototype.checkScrollbar = function () {
if (document.body.clientWidth >= window.innerWidth) return
this.scrollbarWidth = this.scrollbarWidth || this.measureScrollbar()
}
Modal.prototype.setScrollbar = function () { Modal.prototype.setScrollbar = function () {
if (document.body.clientHeight <= window.innerHeight) return var bodyPad = parseInt(this.$body.css('padding-right') || 0)
var scrollbarWidth = this.measureScrollbar() if (this.scrollbarWidth) this.$body.css('padding-right', bodyPad + this.scrollbarWidth)
var bodyPad = parseInt(this.$body.css('padding-right') || 0)
if (scrollbarWidth) this.$body.css('padding-right', bodyPad + scrollbarWidth)
} }
Modal.prototype.resetScrollbar = function () { Modal.prototype.resetScrollbar = function () {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment