Skip to content
This repository has been archived by the owner on Apr 1, 2020. It is now read-only.

Commit

Permalink
enable tooltip to be used on non-block elements
Browse files Browse the repository at this point in the history
  • Loading branch information
andygnewman committed Mar 28, 2017
1 parent b51da6d commit 2202948
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion components/n-ui/tooltip/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ export class NToolTip{
}

position (){
let left = (this.el.offsetLeft - (this.tooltip.offsetWidth / 2));
const elRect = this.el.getClientRects()[0];
const parentRect = this.el.parentNode.getClientRects()[0];
let left = (elRect.left - parentRect.left) + (elRect.width / 2) - (this.tooltip.offsetWidth / 2);
// the magic 15 is to account for the triangle
let top = (this.el.offsetTop + this.el.clientHeight + 15);
if(left < 20){
Expand Down
2 changes: 1 addition & 1 deletion components/n-ui/tooltip/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ $triangle-size:15px;
content: "";
position: absolute;
top: -30px;
left: 50%;
left: calc(50% + 15px);
transform: translateX(-100%);
border: $triangle-size solid transparent;
border-bottom-color: white;
Expand Down

0 comments on commit 2202948

Please sign in to comment.