summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Schneider2012-10-24 15:08:25 +0000
committerChristian Schneider2012-10-24 15:08:25 +0000
commit3096e29943f18335b895f64c98c234ef7352ea71 (patch)
tree8ce22d01826730e18078d5578fafb1bd3b2f289c
parent790963cc4a21d6e2c9fcd59caa4db3290ed75b4e (diff)
downloaditools-3096e29943f18335b895f64c98c234ef7352ea71.tar.gz
itools-3096e29943f18335b895f64c98c234ef7352ea71.tar.bz2
itools-3096e29943f18335b895f64c98c234ef7352ea71.zip
Replace hand-made code by standard obj.getBoundingClientRect()
-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 */