mirror of
https://github.com/twbs/bootstrap.git
synced 2025-01-17 09:52:29 +01:00
Better placement for Dropdown + Handle flip of Tooltip/Popover
This commit is contained in:
parent
d5fabf8de5
commit
18e4e851e2
@ -65,8 +65,8 @@ const Dropdown = (($) => {
|
||||
}
|
||||
|
||||
const AttachmentMap = {
|
||||
TOP : 'top',
|
||||
BOTTOM : 'bottom'
|
||||
TOP : 'top-start',
|
||||
BOTTOM : 'bottom-start'
|
||||
}
|
||||
|
||||
const Default = {
|
||||
|
@ -287,6 +287,12 @@ const Tooltip = (($) => {
|
||||
offset : {
|
||||
offset : this.config.offset
|
||||
}
|
||||
},
|
||||
onCreate : (data) => {
|
||||
this._handlePopperPlacementChange(data)
|
||||
},
|
||||
onUpdate : (data) => {
|
||||
this._handlePopperPlacementChange(data)
|
||||
}
|
||||
})
|
||||
|
||||
@ -637,6 +643,12 @@ const Tooltip = (($) => {
|
||||
}
|
||||
}
|
||||
|
||||
_handlePopperPlacementChange(data) {
|
||||
if (data.originalPlacement !== data.placement) {
|
||||
this._cleanTipClass()
|
||||
this.addAttachmentClass(this._getAttachment(data.placement))
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
<div class="container">
|
||||
<h1>Popover <small>Bootstrap Visual Test</small></h1>
|
||||
|
||||
<button type="button" class="btn btn-secondary" data-container="body" data-toggle="popover" data-placement="top" data-content="Vivamus sagittis lacus vel augue laoreet rutrum faucibus.">
|
||||
<button type="button" class="btn btn-secondary" data-container="body" data-toggle="popover" data-placement="top" data-content="Default placement was on top but not enough place">
|
||||
Popover on top
|
||||
</button>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user