mirror of
https://github.com/twbs/bootstrap.git
synced 2025-01-18 10:52:19 +01:00
fix: add padding to navbar-fixed-*
on modal open
This commit is contained in:
parent
0b78f465d3
commit
cf6f867190
18
js/modal.js
18
js/modal.js
@ -23,6 +23,7 @@
|
|||||||
this.originalBodyPad = null
|
this.originalBodyPad = null
|
||||||
this.scrollbarWidth = 0
|
this.scrollbarWidth = 0
|
||||||
this.ignoreBackdropClick = false
|
this.ignoreBackdropClick = false
|
||||||
|
this.fixedContent = '.navbar-fixed-top, .navbar-fixed-bottom'
|
||||||
|
|
||||||
if (this.options.remote) {
|
if (this.options.remote) {
|
||||||
this.$element
|
this.$element
|
||||||
@ -269,11 +270,26 @@
|
|||||||
Modal.prototype.setScrollbar = function () {
|
Modal.prototype.setScrollbar = function () {
|
||||||
var bodyPad = parseInt((this.$body.css('padding-right') || 0), 10)
|
var bodyPad = parseInt((this.$body.css('padding-right') || 0), 10)
|
||||||
this.originalBodyPad = document.body.style.paddingRight || ''
|
this.originalBodyPad = document.body.style.paddingRight || ''
|
||||||
if (this.bodyIsOverflowing) this.$body.css('padding-right', bodyPad + this.scrollbarWidth)
|
var scrollbarWidth = this.scrollbarWidth
|
||||||
|
if (this.bodyIsOverflowing) {
|
||||||
|
this.$body.css('padding-right', bodyPad + scrollbarWidth)
|
||||||
|
$(this.fixedContent).each(function (index, element) {
|
||||||
|
var actualPadding = element.style.paddingRight
|
||||||
|
var calculatedPadding = $(element).css('padding-right')
|
||||||
|
$(element)
|
||||||
|
.data('padding-right', actualPadding)
|
||||||
|
.css('padding-right', parseFloat(calculatedPadding) + scrollbarWidth + 'px')
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Modal.prototype.resetScrollbar = function () {
|
Modal.prototype.resetScrollbar = function () {
|
||||||
this.$body.css('padding-right', this.originalBodyPad)
|
this.$body.css('padding-right', this.originalBodyPad)
|
||||||
|
$(this.fixedContent).each(function (index, element) {
|
||||||
|
var padding = $(element).data('padding-right')
|
||||||
|
$(element).removeData('padding-right')
|
||||||
|
element.style.paddingRight = padding ? padding : ''
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
Modal.prototype.measureScrollbar = function () { // thx walsh
|
Modal.prototype.measureScrollbar = function () { // thx walsh
|
||||||
|
Loading…
x
Reference in New Issue
Block a user