]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Tooltip: merge `isAnimated` checks
authorGeoSot <geo.sotis@gmail.com>
Fri, 26 Nov 2021 00:15:24 +0000 (02:15 +0200)
committerXhmikosR <xhmikosr@gmail.com>
Wed, 1 Dec 2021 16:00:36 +0000 (18:00 +0200)
js/src/tooltip.js

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