From 904efc043d298904d8020df7325bf01a5825a780 Mon Sep 17 00:00:00 2001 From: Johann Date: Tue, 28 Mar 2017 15:55:03 +0200 Subject: Fix different tooltips offset when hovering --- js/src/tooltip.js | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'js/src') diff --git a/js/src/tooltip.js b/js/src/tooltip.js index e750dcecc..fe913e660 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -34,6 +34,7 @@ const Tooltip = (($) => { const JQUERY_NO_CONFLICT = $.fn[NAME] const TRANSITION_DURATION = 150 const CLASS_PREFIX = 'bs-tether' + const TETHER_PREFIX_REGEX = new RegExp(`(^|\\s)${CLASS_PREFIX}\\S+`, 'g') const Default = { animation : true, @@ -340,6 +341,7 @@ const Tooltip = (($) => { tip.parentNode.removeChild(tip) } + this._cleanTipClass() this.element.removeAttribute('aria-describedby') $(this.element).trigger(this.constructor.Event.HIDDEN) this._isTransitioning = false @@ -438,6 +440,14 @@ const Tooltip = (($) => { return AttachmentMap[placement.toUpperCase()] } + _cleanTipClass() { + const $tip = $(this.getTipElement()) + const tabClass = $tip.attr('class').match(TETHER_PREFIX_REGEX) + if (tabClass !== null && tabClass.length > 0) { + $tip.removeClass(tabClass.join('')) + } + } + _setListeners() { const triggers = this.config.trigger.split(' ') -- cgit v1.2.3