From 0907244256d923807c3a4e55f4ea606b9558d0ca Mon Sep 17 00:00:00 2001 From: Tyler Cipriani Date: Mon, 17 Mar 2014 13:04:58 -0600 Subject: Modal body shift fix for IE10/11 Closes #13103 by merging it. --- js/modal.js | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'js') diff --git a/js/modal.js b/js/modal.js index ec358696f..a55363728 100644 --- a/js/modal.js +++ b/js/modal.js @@ -14,11 +14,12 @@ // ====================== var Modal = function (element, options) { - this.options = options - this.$body = $(document.body) - this.$element = $(element) - this.$backdrop = - this.isShown = null + this.options = options + this.$body = $(document.body) + this.$element = $(element) + this.$backdrop = + this.isShown = null + this.scrollbarWidth = 0 if (this.options.remote) { this.$element @@ -49,6 +50,7 @@ this.isShown = true + this.checkScrollbar() this.$body.addClass('modal-open') this.setScrollbar() @@ -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 () { - if (document.body.clientHeight <= window.innerHeight) return - var scrollbarWidth = this.measureScrollbar() - var bodyPad = parseInt(this.$body.css('padding-right') || 0) - if (scrollbarWidth) this.$body.css('padding-right', bodyPad + scrollbarWidth) + var bodyPad = parseInt(this.$body.css('padding-right') || 0) + if (this.scrollbarWidth) this.$body.css('padding-right', bodyPad + this.scrollbarWidth) } Modal.prototype.resetScrollbar = function () { -- cgit v1.2.3