skip to content

Dimensions 1.0

2 min read

Dimensions 1.0 is final! This is a very big release for Dimensions and includes a lot of bug fixes, new features, an automated test suite. So what new features have been added to Dimensions in 1.0?

  • A position method to get the positioned offset.

  • An offsetParent method to get the positioned parent.

  • The scrollTop and scrollLeft methods can now set the value as well as get the value of the scroll offsets.

  • The offset method has some new options:

  • A relativeTo option that provides a way to get the offset relative to a parent element.

  • A lite option that provides a very fast way to get the offset but at the price of accuracy when borders and margins are involved.

Lots of testing has gone into the 1.0 release and lots of bugs have been fixed and browser issues have been normalized. For example, Firefox and Opera include the width of the scroll bar when getting the width/height of the window unlike the other browsers. This issue has been normalized in Dimensions and you can count on getting accurate results cross-browser.

An Example

The Dimensions plugin is built to get accurate results and stay out of your way. For example the position method returns an object with a top and left property. This allows us to pass the result directly to the css. Lets say we wanted to make a static element positioned absolute but so that it stays exactly where it was when static.

var css = { position: 'absolute' };

With just two simple lines of code we can make an element absolutely positioned! In this example I took advantage of the ability to pass in an object to the position method so that I could continue the jQuery chain. I plan on writing about more ways to use the dimensions plugin.

Get Dimensions 1.0

The Dimensions plugin can be downloaded from the Dimensions project page. The zip contains the full source, a minified version and a packed version. You can also grab the latest from SVN

Support, Bugs and Feature Requests

The Dimensions project page has a place to report bugs, issues and request features.