From 3096e29943f18335b895f64c98c234ef7352ea71 Mon Sep 17 00:00:00 2001 From: Christian Schneider Date: Wed, 24 Oct 2012 15:08:25 +0000 Subject: Replace hand-made code by standard obj.getBoundingClientRect() --- itjs/it.js | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) (limited to 'itjs/it.js') 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 */ -- cgit v1.2.3