11/**
22 * --------------------------------------------------------------------------
3- * CoreUI (v3.2.0 ): tooltip.js
3+ * CoreUI (v3.2.1 ): tooltip.js
44 * Licensed under MIT (https://coreui.io/license)
55 *
66 * This component is a modified version of the Bootstrap's tooltip.js
@@ -37,7 +37,7 @@ import SelectorEngine from './dom/selector-engine'
3737 */
3838
3939const NAME = 'tooltip'
40- const VERSION = '3.2.0 '
40+ const VERSION = '3.2.1 '
4141const DATA_KEY = 'coreui.tooltip'
4242const EVENT_KEY = `.${ DATA_KEY } `
4343const CLASS_PREFIX = 'bs-tooltip'
@@ -53,7 +53,7 @@ const DefaultType = {
5353 html : 'boolean' ,
5454 selector : '(string|boolean)' ,
5555 placement : '(string|function)' ,
56- offset : '(number|string |function)' ,
56+ offset : '(array |function)' ,
5757 container : '(string|element|boolean)' ,
5858 boundary : '(string|element)' ,
5959 sanitize : 'boolean' ,
@@ -81,7 +81,7 @@ const Default = {
8181 html : false ,
8282 selector : false ,
8383 placement : 'top' ,
84- offset : 0 ,
84+ offset : [ 0 , 0 ] ,
8585 container : false ,
8686 boundary : 'scrollParent' ,
8787 sanitize : true ,
@@ -497,20 +497,32 @@ class Tooltip {
497497 // this.getTipElement().classList.add(`${CLASS_PREFIX}-${attachment}`)
498498 // }
499499
500+ // _getOffset() {
501+ // const offset = {}
502+
503+ // if (typeof this.config.offset === 'function') {
504+ // offset.fn = data => {
505+ // data.offsets = {
506+ // ...data.offsets,
507+ // ...this.config.offset(data.offsets, this.element) || {}
508+ // }
509+
510+ // return data
511+ // }
512+ // } else {
513+ // offset.offset = this.config.offset
514+ // }
515+
516+ // return offset
517+ // }
518+
500519 _getOffset ( ) {
501- const offset = { }
520+ let offset = [ ]
502521
503522 if ( typeof this . config . offset === 'function' ) {
504- offset . fn = data => {
505- data . offsets = {
506- ...data . offsets ,
507- ...this . config . offset ( data . offsets , this . element ) || { }
508- }
509-
510- return data
511- }
523+ offset = ( { placement, reference, popper } ) => this . config . offset ( ( { placement, reference, popper } ) )
512524 } else {
513- offset . offset = this . config . offset
525+ offset = this . config . offset
514526 }
515527
516528 return offset
@@ -750,7 +762,6 @@ class Tooltip {
750762
751763 _cleanTipClass ( ) {
752764 const tip = this . getTipElement ( )
753- console . log ( this . tip )
754765 const tabClass = tip . getAttribute ( 'class' ) . match ( BSCLS_PREFIX_REGEX )
755766 if ( tabClass !== null && tabClass . length > 0 ) {
756767 tabClass . map ( token => token . trim ( ) )
0 commit comments