summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--itjs/it.js22
1 files changed, 2 insertions, 20 deletions
diff --git a/itjs/it.js b/itjs/it.js
index b31423e..b5e1f56 100644
--- a/itjs/it.js
+++ b/itjs/it.js
@@ -178,30 +178,12 @@ function it_event_void(evt)
/* Get object pixel position. Based on quirksmode.org's code */
function it_get_obj_x(obj)
{
- var curleft = 0;
- if (obj.offsetParent)
- while (obj)
- {
- curleft += obj.offsetLeft;
- obj = obj.offsetParent;
- }
- else if (obj.x)
- curleft += obj.x;
- return curleft;
+ return obj.getBoundingClientRect().left + ((window.pageXOffset !== undefined) ? window.pageXOffset : (document.documentElement || document.body.parentNode || document.body).scrollLeft);
}
function it_get_obj_y(obj)
{
- var curtop = 0;
- if (obj.offsetParent)
- while (obj)
- {
- curtop += obj.offsetTop;
- obj = obj.offsetParent;
- }
- else if (obj.y)
- curtop += obj.y;
- return curtop;
+ return obj.getBoundingClientRect().top + ((window.pageYOffset !== undefined) ? window.pageYOffset : (document.documentElement || document.body.parentNode || document.body).scrollTop);
}
/* Common accessor for dom elements */