MCPcopy Index your code
hub / github.com/prototypejs/prototype / positionedOffset

Function positionedOffset

src/prototype/dom/layout.js:1104–1126  ·  view source on GitHub ↗

* Element.positionedOffset(@element) -> Element.Offset * * Returns `element`'s offset relative to its closest positioned ancestor * (the element that would be returned by [[Element.getOffsetParent]]).

(element)

Source from the content-addressed store, hash-verified

1102 * (the element that would be returned by [[Element.getOffsetParent]]).
1103 **/
1104 function positionedOffset(element) {
1105 element = $(element);
1106
1107 // Account for the margin of the element.
1108 var layout = element.getLayout();
1109
1110 var valueT = 0, valueL = 0;
1111 do {
1112 valueT += element.offsetTop || 0;
1113 valueL += element.offsetLeft || 0;
1114 element = element.offsetParent;
1115 if (element) {
1116 if (isBody(element)) break;
1117 var p = Element.getStyle(element, 'position');
1118 if (p !== 'static') break;
1119 }
1120 } while (element);
1121
1122 valueL -= layout.get('margin-left');
1123 valueT -= layout.get('margin-top');
1124
1125 return new Element.Offset(valueL, valueT);
1126 }
1127
1128 /**
1129 * Element.cumulativeScrollOffset(@element) -> Element.Offset

Callers

nothing calls this directly

Calls 2

$Function · 0.85
isBodyFunction · 0.85

Tested by

no test coverage detected