diff options
author | Christian Schneider | 2012-10-24 15:08:25 +0000 |
---|---|---|
committer | Christian Schneider | 2012-10-24 15:08:25 +0000 |
commit | 3096e29943f18335b895f64c98c234ef7352ea71 (patch) | |
tree | 8ce22d01826730e18078d5578fafb1bd3b2f289c | |
parent | 790963cc4a21d6e2c9fcd59caa4db3290ed75b4e (diff) | |
download | itools-3096e29943f18335b895f64c98c234ef7352ea71.tar.gz itools-3096e29943f18335b895f64c98c234ef7352ea71.tar.bz2 itools-3096e29943f18335b895f64c98c234ef7352ea71.zip |
Replace hand-made code by standard obj.getBoundingClientRect()
-rw-r--r-- | itjs/it.js | 22 |
1 files changed, 2 insertions, 20 deletions
@@ -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 */ |