within :: Position |
This function uses Position.cumulativeOffset to determine element’s offset from the top of the page, then combines those values with element’s height and width to identify the offsets of all four corners of the element. It then compares these coordinates to the x and y arguments, returning true if those coordinates fall within the bounding box of element.
Example
var element = $('some_positioned_element'); Position.cumulativeOffset(element); // -> [100, 100] (item is 100px from the left and top edges of the page) Element.getDimensions(element); // -> { width: 150, height: 150 }
Position.within(element, 200, 200); // -> true
Position.within(element, 260, 260); // -> false |
Prototype API 1.5.0 - prototypejs.org