diff --git a/js/tooltip.js b/js/tooltip.js index f0f8a7c18bd8..2e57c862e27f 100644 --- a/js/tooltip.js +++ b/js/tooltip.js @@ -253,16 +253,18 @@ if (delta.left) offset.left += delta.left else offset.top += delta.top - var arrowDelta = delta.left ? delta.left * 2 - width + actualWidth : delta.top * 2 - height + actualHeight - var arrowPosition = delta.left ? 'left' : 'top' - var arrowOffsetPosition = delta.left ? 'offsetWidth' : 'offsetHeight' + var topBottom = /top|bottom/.test(placement) + var arrowDelta = topBottom ? delta.left * 2 - width + actualWidth : delta.top * 2 - height + actualHeight + var arrowOffsetPosition = topBottom ? 'offsetWidth' : 'offsetHeight' $tip.offset(offset) - this.replaceArrow(arrowDelta, $tip[0][arrowOffsetPosition], arrowPosition) + this.replaceArrow(arrowDelta, $tip[0][arrowOffsetPosition], topBottom) } - Tooltip.prototype.replaceArrow = function (delta, dimension, position) { - this.arrow().css(position, delta ? (50 * (1 - delta / dimension) + '%') : '') + Tooltip.prototype.replaceArrow = function (delta, dimension, rightLeft) { + this.arrow() + .css(rightLeft ? 'left' : 'top', 50 * (1 - delta / dimension) + '%') + .css(rightLeft ? 'top' : 'left', '') } Tooltip.prototype.setContent = function () {