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