Skip to content

Commit

Permalink
Merge pull request #15378 from twbs/fix-ie-modal-scrollbar-for-realz
Browse files Browse the repository at this point in the history
Modal: Work around IE scrollbars not taking up page width
  • Loading branch information
hnrch02 committed Feb 24, 2015
2 parents 68fef8c + 32f62bc commit 16479e9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion js/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,12 @@
}

Modal.prototype.checkScrollbar = function () {
this.bodyIsOverflowing = document.body.scrollHeight > document.documentElement.clientHeight
var fullWindowWidth = window.innerWidth
if (!fullWindowWidth) { // workaround for missing window.innerWidth in IE8
var documentElementRect = document.documentElement.getBoundingClientRect()
fullWindowWidth = documentElementRect.right - Math.abs(documentElementRect.left)
}
this.bodyIsOverflowing = document.body.clientWidth < fullWindowWidth
this.scrollbarWidth = this.measureScrollbar()
}

Expand Down

3 comments on commit 16479e9

@cervengoc
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I completely missed something, but when I tried out the latest code I had problems because of this. Is it really the "width" which should be cared about? Shouldn't it be the body height which really matters? I've checked an earlier version without the IE8 hack and that measured the height, which should be the logical way.

@cervengoc
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also the relation should be opposite in this line (regardless to what it checks the width of height):

this.bodyIsOverflowing = document.body.clientWidth < fullWindowWidth

@hnrch02
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please file a new issue and @ mention me there.

Please sign in to comment.