Tooltip: merge `isAnimated` checks

This commit is contained in:
GeoSot 2021-11-26 02:15:24 +02:00 committed by XhmikosR
parent 53c77c0203
commit 3baeb0a5c1
1 changed files with 7 additions and 5 deletions

View File

@ -271,8 +271,7 @@ class Tooltip extends BaseComponent {
} }
} }
const isAnimated = this.tip.classList.contains(CLASS_NAME_FADE) this._queueCallback(complete, this.tip, this._isAnimated())
this._queueCallback(complete, this.tip, isAnimated)
} }
hide() { hide() {
@ -315,8 +314,7 @@ class Tooltip extends BaseComponent {
this._activeTrigger[TRIGGER_FOCUS] = false this._activeTrigger[TRIGGER_FOCUS] = false
this._activeTrigger[TRIGGER_HOVER] = false this._activeTrigger[TRIGGER_HOVER] = false
const isAnimated = this.tip.classList.contains(CLASS_NAME_FADE) this._queueCallback(complete, this.tip, this._isAnimated())
this._queueCallback(complete, this.tip, isAnimated)
this._hoverState = '' this._hoverState = ''
} }
@ -355,7 +353,7 @@ class Tooltip extends BaseComponent {
tip.setAttribute('id', tipId) tip.setAttribute('id', tipId)
if (this._config.animation) { if (this._isAnimated()) {
tip.classList.add(CLASS_NAME_FADE) tip.classList.add(CLASS_NAME_FADE)
} }
@ -409,6 +407,10 @@ class Tooltip extends BaseComponent {
return context || this.constructor.getOrCreateInstance(event.delegateTarget, this._getDelegateConfig()) return context || this.constructor.getOrCreateInstance(event.delegateTarget, this._getDelegateConfig())
} }
_isAnimated() {
return this._config.animation || (this.tip && this.tip.classList.contains(CLASS_NAME_FADE))
}
_getOffset() { _getOffset() {
const { offset } = this._config const { offset } = this._config