1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-11 16:14:04 +02:00

Better placement for Dropdown + Handle flip of Tooltip/Popover

This commit is contained in:
Johann-S
2017-04-19 10:20:50 +02:00
parent d5fabf8de5
commit 18e4e851e2
3 changed files with 15 additions and 3 deletions

View File

@@ -65,8 +65,8 @@ const Dropdown = (($) => {
} }
const AttachmentMap = { const AttachmentMap = {
TOP : 'top', TOP : 'top-start',
BOTTOM : 'bottom' BOTTOM : 'bottom-start'
} }
const Default = { const Default = {

View File

@@ -287,6 +287,12 @@ const Tooltip = (($) => {
offset : { offset : {
offset : this.config.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 // static

View File

@@ -10,7 +10,7 @@
<div class="container"> <div class="container">
<h1>Popover <small>Bootstrap Visual Test</small></h1> <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 Popover on top
</button> </button>