Bug Tracker

Ticket #2536: _findPos.txt

File _findPos.txt, 732 bytes (added by veljkopopovic, 12 years ago)

Proposed findPos function

Line 
1_findPos: function(obj) {
2var temp = obj;
3while (obj && (obj.type == 'hidden' || obj.nodeType != 1)) {
4obj = obj.nextSibling;
5}
6var curleft = curtop = 0;
7var origcurleft = 0;
8if (obj && obj.offsetParent) {
9curleft = obj.offsetLeft;
10curtop = obj.offsetTop;
11while (obj = obj.offsetParent) {
12origcurleft = curleft;
13curleft += obj.offsetLeft;
14if (curleft < 0) {
15curleft = origcurleft;
16}
17curtop += obj.offsetTop;
18}
19}
20var parentNodes = $(temp).parents().get();
21var parentCounter = 0;
22
23while (parentNodes[parentCounter].tagName.toLowerCase() !="body")
24{
25curleft -= parentNodes[parentCounter].scrollLeft;
26curtop -= parentNodes[parentCounter].scrollTop;
27parentCounter++;
28}
29
30if (curleft<0){curleft = origcurleft;}
31return [curleft,curtop];
32},