Position

The Position object provides a series of methods that help with element positioning and layout-related issues. These are mainly used by third party UI libraries like script.aculo.us.

 


Moduleindex

 

absolutize

 

absolutize(element)

 

Turns element into an absolutely-positioned element without changing its position in the page layout.

 

clone

 

clone(source, target[, options]) -> [Number, Number]

 

Clones the position and/or dimensions of source onto target as defined by the optional argument options.

 

cumulativeOffset

 

cumulativeOffset(element) -> [Number, Number]

 

Returns the offsets of element from the top left corner of the document.

 

offsetParent

 

offsetParent(element) -> HTMLElement

 

Returns element’s closest positioned ancestor. If none is found, the body element is returned.

 

overlap

 

overlap(mode, element) -> Number

 

Returns a Number between 0 and 1 corresponding to the proportion to which element overlaps the point previously defined by Position.within. mode can be set to either vertical or horizontal.

 

page

 

page(element) -> [Number, Number]

 

Returns the X/Y coordinates of element relative to the viewport.

 

positionedOffset

 

positionedOffset(element) -> [Number, Number]

 

Calculates the element’s offset relative to its closest positioned ancestor (i.e., the element that would be returned by Position.offsetParent(element).

 

prepare

 

prepare()

 

Calculates document scroll offsets for use with Position.withinIncludingScrollOffsets.

 

realOffset

 

realOffset(element) -> [Number, Number]

 

Calculates the cumulative scroll offset of an element in nested scrolling containers.

 

relativize

 

relativize(element)

 

Turns element into an relatively-positioned element without changing its position in the page layout.

 

within

 

within(element, x, y) -> Boolean

 

Indicates whether the point x, y (measured from the top-left corner of the document) is within the boundaries of element. Must be called immediately before Position.overlap.

 

withinIncludingScrolloffsets

 

withinIncludingScrollOffsets(element, x, y) -> Boolean

 

Indicates whether the point x, y (measured from the top-left corner of the document) is within the boundaries of element. Used instead of Position.within whenever element is a child of a scrolling container. Must be called immediately before Position.overlap and immediately after Position.prepare.

 


Prototype API 1.5.0 - prototypejs.org