Element.Dimensions

This file contains all the logic needed to figure out the size of things and a few helpers like .scrollTo.

Element.scrollTo

Scrolls an element to the coordinates you specify; note that this isn't a smooth transition; it just jumps to that location.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

$('scrollExample').scrollTo(0, 30); //jump 30px down
execute this code

Element.getSize

Returns an object with x/y definitions for size (width/height).

$('getSizeExample').getSize();
//returns something like:
//{
//	x=660,
//  y=44
//}
execute this code

Element.getScrollSize

Returns an object with x/y definitions for scroll size (the total width/height that an element can scroll).

$('scrollExample').getSize();
//returns something like:
//{
//	x=660,
//  y=44
//}
execute this code

Element.getScroll

Returns an object with x/y definitions for scroll position (the scroll offset for the top and left).

$('scrollExample').getScroll();
//returns something like:
//{
//	x=0,
//  y=20 (whatever the scroll offset is above)
//}
execute this code

Element.getPosition

Returns an object with the offsetLeft and offsetTop as x and y properties:

$('positionExample').getPosition();
//returns something like {x:20, y:570}
execute this code

Element.getCoordinates

Returns an object with definitions for width, height, left and top:

$('getCoordinatesExample').getCoordinates ();
//returns something like:
//{
//	width:660,
//	height:37,
//	left:20,
//	right:680,
//	top:13033
//}
execute this code

Deprecated Methods

  • Element.getSize previously returned an object with scroll, size, and scroll position, so this has changed dramatically

* Element.getTop and getLeft are replaced by Element.getPosition

mootorial/04-element/03-element.dimensions.txt · Last modified: 2008/10/27 23:53