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
diff options
context:
space:
mode:
authorRoman O <ceo.roman@gmail.com>2017-10-03 15:34:44 +0300
committerJohann-S <johann.servoire@gmail.com>2017-10-03 15:34:44 +0300
commit527f55c2f3fecfbc1e991263d646a32de4ffcded (patch)
tree1dbdccbbbe52d2e2982e157e7a0ca0e6ec0c8b5a /js
parent898708dd2770645c0987fdcb52e12e1c739bca88 (diff)
Offset option for dropdown can be function (#24222)
* Offset option can be function (Popper.js) * Fix...add function type for offset option * Remove constants for popper config * Optimize code. Remove foreach loop. * Refactoring. Remove getOffset method
Diffstat (limited to 'js')
-rw-r--r--js/src/dropdown.js15
1 files changed, 11 insertions, 4 deletions
diff --git a/js/src/dropdown.js b/js/src/dropdown.js
index f76f84ef0a..6681df668c 100644
--- a/js/src/dropdown.js
+++ b/js/src/dropdown.js
@@ -80,7 +80,7 @@ const Dropdown = (() => {
}
const DefaultType = {
- offset : '(number|string)',
+ offset : '(number|string|function)',
flip : 'boolean'
}
@@ -246,12 +246,19 @@ const Dropdown = (() => {
}
_getPopperConfig() {
+ const offsetConf = {}
+ if (typeof this._config.offset === 'function') {
+ offsetConf.fn = (data) => {
+ data.offsets = $.extend({}, data.offsets, this._config.offset(data.offsets) || {})
+ return data
+ }
+ } else {
+ offsetConf.offset = this._config.offset
+ }
const popperConfig = {
placement : this._getPlacement(),
modifiers : {
- offset : {
- offset : this._config.offset
- },
+ offset : offsetConf,
flip : {
enabled : this._config.flip
}