Side navigation
Ticket #2536: _findPos.txt
File _findPos.txt, 0.7 KB (added by veljkopopovic, April 14, 2008 12:40PM UTC)
Proposed findPos function
_findPos: function(obj) {
var temp = obj;
while (obj && (obj.type == 'hidden' || obj.nodeType != 1)) {
obj = obj.nextSibling;
}
var curleft = curtop = 0;
var origcurleft = 0;
if (obj && obj.offsetParent) {
curleft = obj.offsetLeft;
curtop = obj.offsetTop;
while (obj = obj.offsetParent) {
origcurleft = curleft;
curleft += obj.offsetLeft;
if (curleft < 0) {
curleft = origcurleft;
}
curtop += obj.offsetTop;
}
}
var parentNodes = $(temp).parents().get();
var parentCounter = 0;
while (parentNodes[parentCounter].tagName.toLowerCase() !="body")
{
curleft -= parentNodes[parentCounter].scrollLeft;
curtop -= parentNodes[parentCounter].scrollTop;
parentCounter++;
}
if (curleft<0){curleft = origcurleft;}
return [curleft,curtop];
},
Download in other formats:
Original Format
File _findPos.txt, 0.7 KB (added by veljkopopovic, April 14, 2008 12:40PM UTC)
Proposed findPos function
_findPos: function(obj) {
var temp = obj;
while (obj && (obj.type == 'hidden' || obj.nodeType != 1)) {
obj = obj.nextSibling;
}
var curleft = curtop = 0;
var origcurleft = 0;
if (obj && obj.offsetParent) {
curleft = obj.offsetLeft;
curtop = obj.offsetTop;
while (obj = obj.offsetParent) {
origcurleft = curleft;
curleft += obj.offsetLeft;
if (curleft < 0) {
curleft = origcurleft;
}
curtop += obj.offsetTop;
}
}
var parentNodes = $(temp).parents().get();
var parentCounter = 0;
while (parentNodes[parentCounter].tagName.toLowerCase() !="body")
{
curleft -= parentNodes[parentCounter].scrollLeft;
curtop -= parentNodes[parentCounter].scrollTop;
parentCounter++;
}
if (curleft<0){curleft = origcurleft;}
return [curleft,curtop];
},