Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tooltip arrow fixes #13718

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions js/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) + '%')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why'd you remove the delta-related ternary?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because if delta is zero it removes the css value, which resets it to 50%, but if delta is zero it will always be 50% anyway.

.css(rightLeft ? 'top' : 'left', '')
}

Tooltip.prototype.setContent = function () {
Expand Down