Skip to content
This repository was archived by the owner on Nov 17, 2025. It is now read-only.

Commit fc83c76

Browse files
committed
Merge pull request #40 from noahbornstein/patch-1
Make tooltip offsets relative to the viewport
2 parents 1e63201 + 33e376a commit fc83c76

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

src/js/angular-tooltips.js

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -100,24 +100,12 @@
100100
}
101101
};
102102

103-
$scope.getRootOffsetTop = function getRootOffsetTop (elem, val){
104-
105-
if (elem.offsetParent === null){
106-
107-
return val + elem.offsetTop;
108-
}
109-
110-
return $scope.getRootOffsetTop(elem.offsetParent, val + elem.offsetTop);
103+
$scope.getRootOffsetTop = function getRootOffsetTop (elem){
104+
return elem.getBoundingClientRect().top;
111105
};
112106

113-
$scope.getRootOffsetLeft = function getRootOffsetLeft (elem, val){
114-
115-
if (elem.offsetParent === null){
116-
117-
return val + elem.offsetLeft;
118-
}
119-
120-
return $scope.getRootOffsetLeft(elem.offsetParent, val + elem.offsetLeft);
107+
$scope.getRootOffsetLeft = function getRootOffsetLeft (elem){
108+
return elem.getBoundingClientRect().left;
121109
};
122110

123111
$scope.bindShowTriggers = function() {

0 commit comments

Comments
 (0)