Fx.Sort
This effect will rearrange a group of elements using a transition. Note: this effect is not recommended for very large sets of elements.
Elements must all be contained by the same parent, and it will work best if these elements are the only children in that parent (for instance, all the list items in a list). Additionally, the effect will set their position to be relative if they are not positioned. Absolutely positioned elements will likely have trouble (I haven't tested that out yet).
Here's what it looks like to create one:
var mySort = new Fx.Sort($$('ul li')); mySort.sort([3,2,1,0]); //specify a specific order mySort.forward(); //0,1,2,3,etc.
Here's a quick demo (I've already created the instance of the effect for this demo):
- (0) stuff
- (1) more stuff
really - (2) still more stuff
- (3) loads o stuff
- (4) blah
blah
blah
forward | backward | 3,4,2,0,1 | 2,3,0,1,4
: :
In addition to specifying a new order using numbers, there are some other methods.
vert.forward(); //0,1,2,3,etc.

vert.backward(); //3,2,1,0

vert.swap(3,1);

vert.reverse(); //reverses the current order

Finally, you can sort a list and then rearrange the DOM so that the new sort is reflected in the body of the document.
vert.backward().chain(vert.rearrangeDOM.bind(vert));

cnet-libraries/05-fx/03-fx.sort.txt · Last modified: 2008/11/17 23:25