Skip to content
This repository has been archived by the owner on Dec 19, 2024. It is now read-only.

Commit

Permalink
Fix paper tooltip fit to visible bounds.
Browse files Browse the repository at this point in the history
There are 3 cases that can happen with fit to visible bounds (Using left/right for simplicity here)

1) Off the right of the screen
2) Off the left of the screen
3) In the middle of the screen (no adjustment required)

Paper tooltip failed to handle case (3).

Fix that.
  • Loading branch information
John Palmer committed Jul 8, 2021
1 parent 67a2272 commit 78a7f6f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions paper-tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -473,17 +473,21 @@ Polymer({
if (parentRect.left + tooltipLeft + thisRect.width > window.innerWidth) {
this.style.right = '0px';
this.style.left = 'auto';
} else {
} else if (parentRect.left + tooltipLeft < 0) {
this.style.left = Math.max(0, tooltipLeft) + 'px';
this.style.right = 'auto';
} else {
this.style.left = tooltipLeft + 'px';
}
// Clip the top/bottom side.
if (parentRect.top + tooltipTop + thisRect.height > window.innerHeight) {
this.style.bottom = (parentRect.height - targetTop + offset) + 'px';
this.style.top = 'auto';
} else {
} else if (parentRect.top + tooltipTop < 0) {
this.style.top = Math.max(-parentRect.top, tooltipTop) + 'px';
this.style.bottom = 'auto';
} else {
this.style.top = tooltipTop + 'px';
}
} else {
this.style.left = tooltipLeft + 'px';
Expand Down

0 comments on commit 78a7f6f

Please sign in to comment.