doc: Clarified units in Element.cumulativeOffset and added example.

This commit is contained in:
tjcrowder 2009-10-09 17:01:40 +01:00
parent c448b38f7b
commit f1f6fca60b
1 changed files with 15 additions and 1 deletions

View File

@ -1124,10 +1124,24 @@ Element.Methods = {
* Element.cumulativeOffset(@element) -> Array
*
* Returns the offsets of `element` from the top left corner of the
* document.
* document, in pixels.
*
* Returns an array in the form of `[leftValue, topValue]`. Also accessible
* as properties: `{ left: leftValue, top: topValue }`.
*
* ##### Example
*
* Assuming the div `foo` is at (25,40), then:
*
* var offset = $('foo').cumulativeOffset();
* offset[0];
* // -> 25
* offset[1];
* // -> 40
* offset.left;
* // -> 25
* offset.top;
* // -> 40
**/
cumulativeOffset: function(element) {
var valueT = 0, valueL = 0;