0
0
mirror of https://github.com/twbs/bootstrap.git synced 2024-11-29 11:24:18 +01:00

test(Modal): reuse _getScrollbarWidth in tests

This commit is contained in:
Andrew Luca 2018-10-21 13:15:35 +03:00 committed by Johann-S
parent ff9b195da7
commit 1f1308ba22

View File

@ -13,14 +13,7 @@ $(function () {
// Enable the scrollbar measurer
$('<style type="text/css"> .modal-scrollbar-measure { position: absolute; top: -9999px; width: 50px; height: 50px; overflow: scroll; } </style>').appendTo('head')
// Function to calculate the scrollbar width which is then compared to the padding or margin changes
$.fn.getScrollbarWidth = function () {
var scrollDiv = document.createElement('div')
scrollDiv.className = 'modal-scrollbar-measure'
document.body.appendChild(scrollDiv)
var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth
document.body.removeChild(scrollDiv)
return scrollbarWidth
}
$.fn.getScrollbarWidth = $.fn.modal.Constructor.prototype._getScrollbarWidth
// Simulate scrollbars
$('html').css('padding-right', '16px')