mirror of
https://github.com/twbs/bootstrap.git
synced 2024-12-01 13:24:25 +01:00
fixes #8568 -- account for margins in offset
This commit is contained in:
parent
aad910465c
commit
e9c83647af
23
dist/js/bootstrap.js
vendored
23
dist/js/bootstrap.js
vendored
@ -1191,7 +1191,6 @@
|
|||||||
|
|
||||||
this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)
|
this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)
|
||||||
|
|
||||||
var tp
|
|
||||||
var pos = this.getPosition()
|
var pos = this.getPosition()
|
||||||
var actualWidth = $tip[0].offsetWidth
|
var actualWidth = $tip[0].offsetWidth
|
||||||
var actualHeight = $tip[0].offsetHeight
|
var actualHeight = $tip[0].offsetHeight
|
||||||
@ -1216,20 +1215,10 @@
|
|||||||
.addClass(placement)
|
.addClass(placement)
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (placement) {
|
var tp = placement == 'bottom' ? { top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2 } :
|
||||||
case 'bottom':
|
placement == 'top' ? { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2 } :
|
||||||
tp = {top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2}
|
placement == 'left' ? { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth } :
|
||||||
break
|
/* placement == 'right' */ { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width }
|
||||||
case 'top':
|
|
||||||
tp = {top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2}
|
|
||||||
break
|
|
||||||
case 'left':
|
|
||||||
tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth}
|
|
||||||
break
|
|
||||||
case 'right':
|
|
||||||
tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width}
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
this.applyPlacement(tp, placement)
|
this.applyPlacement(tp, placement)
|
||||||
this.$element.trigger('shown.bs.' + this.type)
|
this.$element.trigger('shown.bs.' + this.type)
|
||||||
@ -1242,6 +1231,10 @@
|
|||||||
var width = $tip[0].offsetWidth
|
var width = $tip[0].offsetWidth
|
||||||
var height = $tip[0].offsetHeight
|
var height = $tip[0].offsetHeight
|
||||||
|
|
||||||
|
// manually read margins because getBoundingClientRect includes difference
|
||||||
|
offset.top = offset.top + parseInt($tip.css('margin-top'), 10)
|
||||||
|
offset.left = offset.left + parseInt($tip.css('margin-left'), 10)
|
||||||
|
|
||||||
$tip
|
$tip
|
||||||
.offset(offset)
|
.offset(offset)
|
||||||
.addClass('in')
|
.addClass('in')
|
||||||
|
2
dist/js/bootstrap.min.js
vendored
2
dist/js/bootstrap.min.js
vendored
File diff suppressed because one or more lines are too long
@ -155,7 +155,6 @@
|
|||||||
|
|
||||||
this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)
|
this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)
|
||||||
|
|
||||||
var tp
|
|
||||||
var pos = this.getPosition()
|
var pos = this.getPosition()
|
||||||
var actualWidth = $tip[0].offsetWidth
|
var actualWidth = $tip[0].offsetWidth
|
||||||
var actualHeight = $tip[0].offsetHeight
|
var actualHeight = $tip[0].offsetHeight
|
||||||
@ -180,20 +179,10 @@
|
|||||||
.addClass(placement)
|
.addClass(placement)
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (placement) {
|
var tp = placement == 'bottom' ? { top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2 } :
|
||||||
case 'bottom':
|
placement == 'top' ? { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2 } :
|
||||||
tp = {top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2}
|
placement == 'left' ? { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth } :
|
||||||
break
|
/* placement == 'right' */ { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width }
|
||||||
case 'top':
|
|
||||||
tp = {top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2}
|
|
||||||
break
|
|
||||||
case 'left':
|
|
||||||
tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth}
|
|
||||||
break
|
|
||||||
case 'right':
|
|
||||||
tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width}
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
this.applyPlacement(tp, placement)
|
this.applyPlacement(tp, placement)
|
||||||
this.$element.trigger('shown.bs.' + this.type)
|
this.$element.trigger('shown.bs.' + this.type)
|
||||||
@ -206,6 +195,10 @@
|
|||||||
var width = $tip[0].offsetWidth
|
var width = $tip[0].offsetWidth
|
||||||
var height = $tip[0].offsetHeight
|
var height = $tip[0].offsetHeight
|
||||||
|
|
||||||
|
// manually read margins because getBoundingClientRect includes difference
|
||||||
|
offset.top = offset.top + parseInt($tip.css('margin-top'), 10)
|
||||||
|
offset.left = offset.left + parseInt($tip.css('margin-left'), 10)
|
||||||
|
|
||||||
$tip
|
$tip
|
||||||
.offset(offset)
|
.offset(offset)
|
||||||
.addClass('in')
|
.addClass('in')
|
||||||
|
Loading…
Reference in New Issue
Block a user