1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-08 06:36:33 +02:00

Restore offset option for tooltip/popover components

This commit is contained in:
Rohit Sharma
2020-12-16 20:07:27 +02:00
committed by XhmikosR
parent 881f43a3b9
commit b1bd54955e
2 changed files with 57 additions and 0 deletions

View File

@@ -50,6 +50,7 @@ const DefaultType = {
html: 'boolean',
selector: '(string|boolean)',
placement: '(string|function)',
offset: '(array|string|function)',
container: '(string|element|boolean)',
fallbackPlacements: 'array',
boundary: '(string|element)',
@@ -80,6 +81,7 @@ const Default = {
html: false,
selector: false,
placement: 'top',
offset: [0, 0],
container: false,
fallbackPlacements: ['top', 'right', 'bottom', 'left'],
boundary: 'clippingParents',
@@ -473,6 +475,20 @@ class Tooltip extends BaseComponent {
return context
}
_getOffset() {
const { offset } = this.config
if (typeof offset === 'string') {
return offset.split(',').map(val => Number.parseInt(val, 10))
}
if (typeof offset === 'function') {
return popperData => offset(popperData, this._element)
}
return offset
}
_getPopperConfig(attachment) {
const defaultBsConfig = {
placement: attachment,
@@ -484,6 +500,12 @@ class Tooltip extends BaseComponent {
fallbackPlacements: this.config.fallbackPlacements
}
},
{
name: 'offset',
options: {
offset: this._getOffset()
}
},
{
name: 'preventOverflow',
options: {