mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-11 08:04:59 +02:00
Add fallbackPlacement option for Tooltip and Popover
This commit is contained in:
@@ -264,6 +264,13 @@ Options can be passed via data attributes or JavaScript. For data attributes, ap
|
|||||||
<td>0</td>
|
<td>0</td>
|
||||||
<td>Offset of the popover relative to its target. For more information refer to Popper.js's <a href="https://popper.js.org/popper-documentation.html#modifiers..offset.offset">offset docs</a>.</td>
|
<td>Offset of the popover relative to its target. For more information refer to Popper.js's <a href="https://popper.js.org/popper-documentation.html#modifiers..offset.offset">offset docs</a>.</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>fallbackPlacement</td>
|
||||||
|
<td>string | array</td>
|
||||||
|
<td>['top', 'right', 'bottom', 'left']</td>
|
||||||
|
<td>Allow to specify which position Popper will use on fallback. For more information refer to
|
||||||
|
Popper.js's <a href="https://popper.js.org/popper-documentation.html#modifiers..flip.behavior">behavior docs</a></td>
|
||||||
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
@@ -242,6 +242,13 @@ Options can be passed via data attributes or JavaScript. For data attributes, ap
|
|||||||
<td>0</td>
|
<td>0</td>
|
||||||
<td>Offset of the tooltip relative to its target. For more information refer to Popper.js's <a href="https://popper.js.org/popper-documentation.html#modifiers..offset.offset">offset docs</a>.</td>
|
<td>Offset of the tooltip relative to its target. For more information refer to Popper.js's <a href="https://popper.js.org/popper-documentation.html#modifiers..offset.offset">offset docs</a>.</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>fallbackPlacement</td>
|
||||||
|
<td>string | array</td>
|
||||||
|
<td>['top', 'right', 'bottom', 'left']</td>
|
||||||
|
<td>Allow to specify which position Popper will use on fallback. For more information refer to
|
||||||
|
Popper.js's <a href="https://popper.js.org/popper-documentation.html#modifiers..flip.behavior">behavior docs</a></td>
|
||||||
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
@@ -157,7 +157,8 @@ const Dropdown = (($) => {
|
|||||||
offset : context._config.offset
|
offset : context._config.offset
|
||||||
},
|
},
|
||||||
flip : {
|
flip : {
|
||||||
enabled : context._config.flip
|
enabled : context._config.flip,
|
||||||
|
behavior : [AttachmentMap.TOP, AttachmentMap.BOTTOM]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@@ -36,6 +36,27 @@ const Tooltip = (($) => {
|
|||||||
const CLASS_PREFIX = 'bs-tooltip'
|
const CLASS_PREFIX = 'bs-tooltip'
|
||||||
const BSCLS_PREFIX_REGEX = new RegExp(`(^|\\s)${CLASS_PREFIX}\\S+`, 'g')
|
const BSCLS_PREFIX_REGEX = new RegExp(`(^|\\s)${CLASS_PREFIX}\\S+`, 'g')
|
||||||
|
|
||||||
|
const DefaultType = {
|
||||||
|
animation : 'boolean',
|
||||||
|
template : 'string',
|
||||||
|
title : '(string|element|function)',
|
||||||
|
trigger : 'string',
|
||||||
|
delay : '(number|object)',
|
||||||
|
html : 'boolean',
|
||||||
|
selector : '(string|boolean)',
|
||||||
|
placement : '(string|function)',
|
||||||
|
offset : '(number|string)',
|
||||||
|
container : '(string|element|boolean)',
|
||||||
|
fallbackPlacement : '(string|array)'
|
||||||
|
}
|
||||||
|
|
||||||
|
const AttachmentMap = {
|
||||||
|
TOP : 'top',
|
||||||
|
RIGHT : 'right',
|
||||||
|
BOTTOM : 'bottom',
|
||||||
|
LEFT : 'left'
|
||||||
|
}
|
||||||
|
|
||||||
const Default = {
|
const Default = {
|
||||||
animation : true,
|
animation : true,
|
||||||
template : '<div class="tooltip" role="tooltip">'
|
template : '<div class="tooltip" role="tooltip">'
|
||||||
@@ -48,27 +69,8 @@ const Tooltip = (($) => {
|
|||||||
selector : false,
|
selector : false,
|
||||||
placement : 'top',
|
placement : 'top',
|
||||||
offset : 0,
|
offset : 0,
|
||||||
container : false
|
container : false,
|
||||||
}
|
fallbackPlacement : [AttachmentMap.TOP, AttachmentMap.RIGHT, AttachmentMap.BOTTOM, AttachmentMap.LEFT]
|
||||||
|
|
||||||
const DefaultType = {
|
|
||||||
animation : 'boolean',
|
|
||||||
template : 'string',
|
|
||||||
title : '(string|element|function)',
|
|
||||||
trigger : 'string',
|
|
||||||
delay : '(number|object)',
|
|
||||||
html : 'boolean',
|
|
||||||
selector : '(string|boolean)',
|
|
||||||
placement : '(string|function)',
|
|
||||||
offset : '(number|string)',
|
|
||||||
container : '(string|element|boolean)'
|
|
||||||
}
|
|
||||||
|
|
||||||
const AttachmentMap = {
|
|
||||||
TOP : 'top',
|
|
||||||
RIGHT : 'right',
|
|
||||||
BOTTOM : 'bottom',
|
|
||||||
LEFT : 'left'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const HoverState = {
|
const HoverState = {
|
||||||
@@ -289,6 +291,9 @@ const Tooltip = (($) => {
|
|||||||
modifiers : {
|
modifiers : {
|
||||||
offset : {
|
offset : {
|
||||||
offset : this.config.offset
|
offset : this.config.offset
|
||||||
|
},
|
||||||
|
flip : {
|
||||||
|
behavior : this.config.fallbackPlacement
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onCreate : (data) => {
|
onCreate : (data) => {
|
||||||
|
Reference in New Issue
Block a user