Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/js/src
diff options
context:
space:
mode:
authorJason Golieb <jgolieb@hortonworks.com>2019-01-28 23:55:21 +0300
committerXhmikosR <xhmikosr@gmail.com>2019-02-05 11:24:49 +0300
commit88a34aacbee09417252c804f7cded926a496904a (patch)
treed604f307ea420b376b4a41f8f32052faaab7804c /js/src
parent1accd37aa07fa15485a85a9e2ff316aaba51333e (diff)
Add support for tooltip offset option to be a function.
Diffstat (limited to 'js/src')
-rw-r--r--js/src/tooltip.js16
1 files changed, 12 insertions, 4 deletions
diff --git a/js/src/tooltip.js b/js/src/tooltip.js
index 366781b3e8..0b6e21085f 100644
--- a/js/src/tooltip.js
+++ b/js/src/tooltip.js
@@ -32,7 +32,7 @@ const DefaultType = {
html : 'boolean',
selector : '(string|boolean)',
placement : '(string|function)',
- offset : '(number|string)',
+ offset : '(number|string|function)',
container : '(string|element|boolean)',
fallbackPlacement : '(string|array)',
boundary : '(string|element)'
@@ -273,6 +273,16 @@ class Tooltip {
const attachment = this._getAttachment(placement)
this.addAttachmentClass(attachment)
+ const offsetConf = {}
+ if (typeof this.config.offset === 'function') {
+ offsetConf.fn = (data) => {
+ data.offsets = $.extend({}, data.offsets, this.config.offset(data.offsets, this.element) || {})
+ return data
+ }
+ } else {
+ offsetConf.offset = this.config.offset
+ }
+
const container = this._getContainer()
$(tip).data(this.constructor.DATA_KEY, this)
@@ -285,9 +295,7 @@ class Tooltip {
this._popper = new Popper(this.element, tip, {
placement: attachment,
modifiers: {
- offset: {
- offset: this.config.offset
- },
+ offset: offsetConf,
flip: {
behavior: this.config.fallbackPlacement
},