MCPcopy Create free account
hub / github.com/controlsjs/controls.js / ng_ParentPosition

Function ng_ParentPosition

src/ng_basic/basic.js:1540–1577  ·  view source on GitHub ↗

* Function: ng_ParentPosition * Determines absolute position to parent object or document. * * Syntax: * int *ng_ParentPosition* (object obj[, object parent]) * * Parameters: * obj - element object * parent - element object * * Returns: * Object with properti

(o, parent)

Source from the content-addressed store, hash-verified

1538 * Object with properties x and y.
1539 */
1540function ng_ParentPosition(o, parent)
1541{
1542 var n=o,pn;
1543 var pos=new Object;
1544 pos.x=0;
1545 pos.y=0;
1546 if(typeof parent === 'undefined') parent=document.body;
1547 while((n)&&(n!=parent))
1548 {
1549 pn=n.offsetParent;
1550 pos.x += n.offsetLeft + ng_GetCurrentStylePx(n,'border-left-width');
1551 pos.y += n.offsetTop + ng_GetCurrentStylePx(n,'border-top-width');
1552 if((pn)&&(pn!=parent))
1553 {
1554 pos.x -= pn.scrollLeft;
1555 pos.y -= pn.scrollTop;
1556 }
1557 if(ngFireFox)
1558 {
1559 if((ng_GetCurrentStyle(n,'overflow')!=='auto')||((ngFireFox1x)||(ngFireFox2x)))
1560 {
1561 pos.x+=ng_GetCurrentStylePx(n,'border-left-width');
1562 pos.y+=ng_GetCurrentStylePx(n,'border-top-width');
1563 }
1564
1565 }
1566 else
1567 {
1568 if(ngOpera)
1569 {
1570 pos.x -=ng_GetCurrentStylePx(n,'border-left-width');
1571 pos.y -=ng_GetCurrentStylePx(n,'border-top-width');
1572 }
1573 }
1574 n=pn;
1575 }
1576 return pos;
1577}
1578
1579
1580/**

Callers 4

ngmn_PopupCtrlFunction · 0.85
ngmn_PopupSubMenuFunction · 0.85
nge_DropDownFunction · 0.85
ngh_PopupCtrlFunction · 0.85

Calls 2

ng_GetCurrentStylePxFunction · 0.85
ng_GetCurrentStyleFunction · 0.85

Tested by

no test coverage detected