Skip to content

Commit

Permalink
Fixed #1383
Browse files Browse the repository at this point in the history
  • Loading branch information
Çağatay Çivici committed Nov 21, 2016
1 parent 611f2d3 commit 889833c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
12 changes: 12 additions & 0 deletions components/dom/domhandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,18 @@ export class DomHandler {

return { width: w, height: h };
}

public getOffset(el) {
let x = el.offsetLeft;
let y = el.offsetTop;

while (el = el.offsetParent) {
x += el.offsetLeft;
y += el.offsetTop;
}

return {left: x, top: y};
}

public equals(obj1: any, obj2: any): boolean {
if (obj1 == null && obj2 == null) {
Expand Down
5 changes: 3 additions & 2 deletions components/tooltip/tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ export class Tooltip implements OnDestroy {
}

this.create();
let targetTop = this.el.nativeElement.offsetTop;
let targetLeft = this.el.nativeElement.offsetLeft;
let offset = this.domHandler.getOffset(this.el.nativeElement);
let targetTop = offset.top;
let targetLeft = offset.left;
let left: number;
let top: number;

Expand Down

0 comments on commit 889833c

Please sign in to comment.