diff options
| author | Johann-S <[email protected]> | 2017-04-19 10:20:50 +0200 |
|---|---|---|
| committer | Johann-S <[email protected]> | 2017-05-14 11:41:19 +0200 |
| commit | 18e4e851e2829aedc6d1ff2b703ba5cae2c0a288 (patch) | |
| tree | aa7b385be6564bbaaeede9870ff991fc2789384e /js | |
| parent | d5fabf8de50710c5a09ecd91f4b9e961e67d7937 (diff) | |
| download | bootstrap-18e4e851e2829aedc6d1ff2b703ba5cae2c0a288.tar.xz bootstrap-18e4e851e2829aedc6d1ff2b703ba5cae2c0a288.zip | |
Better placement for Dropdown + Handle flip of Tooltip/Popover
Diffstat (limited to 'js')
| -rw-r--r-- | js/src/dropdown.js | 4 | ||||
| -rw-r--r-- | js/src/tooltip.js | 12 | ||||
| -rw-r--r-- | js/tests/visual/popover.html | 2 |
3 files changed, 15 insertions, 3 deletions
diff --git a/js/src/dropdown.js b/js/src/dropdown.js index d678a3a02..613a23812 100644 --- a/js/src/dropdown.js +++ b/js/src/dropdown.js @@ -65,8 +65,8 @@ const Dropdown = (($) => { } const AttachmentMap = { - TOP : 'top', - BOTTOM : 'bottom' + TOP : 'top-start', + BOTTOM : 'bottom-start' } const Default = { diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 2c34ac5d7..b446d9bcc 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -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 diff --git a/js/tests/visual/popover.html b/js/tests/visual/popover.html index 4fd813c06..93fa01f9d 100644 --- a/js/tests/visual/popover.html +++ b/js/tests/visual/popover.html @@ -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> |
