GitXplorerGitXplorer
m

massanimate

public
9 stars
1 forks
2 issues

Commits

List of commits on branch master.
Unverified
84c45aba5618a51ecbb556838a9ae887a102aec0

Allow to access the style rule.

committed 14 years ago
Unverified
0d989d7cdbfa81cdaf53cdf156356f686d7d8c62

Some changes cause of unresolved issue #1.

committed 14 years ago
Unverified
a7e5c392acc4c807f42e8b03a2ccdf1af99cda2c

Added test suite.

committed 14 years ago
Unverified
05c002e8732a53911a120efeb3926c6978d51b32

More concise.

committed 14 years ago
Unverified
37baec5ca0a701115d9a2a60ec2e274ae2af7c02

Minor Readme edit.

committed 14 years ago
Unverified
ab2367cbb3926b2a7eacf2c410020f612042cca9

Improved the demo a bit.

committed 14 years ago

README

The README file for this repository.

jQuery Mass Animate

About

jQuery Mass Animate is a tiny but very powerful jQuery extension. It allows to animate hundreds of elements at once and synchronously by using stylesheet rules (instead of animating each element style like normally jQuery does).

Demo

Dependencies

It should work with jQuery >= 1.4.3. Tested with Firefox 3/4, Chrome, Opera 11, IE 7/8/9 on Windows and Linux.

Usage

Simply add a class (e.g. "mass-animate") to all elements you would like to animate (this is usually pretty fast). Then use massanimate like below:

$.massanimate("div.mass-animate") // creates a new empty style rule
.css({width: 50, height: 50, opacity: 0}) // set some initial style attributes
.animate({width: 100, height: 100, opacity: 1}, 2000) // animate those attributes
.animate({width: 50, height: 50, opacity: 0}, 2000, function() { // another animation
	// `this` is the massanimate object
	// do something afterwards
	var rule = this.rule(); // access the style rule (returns a CSSStyleRule object)
	this.remove(); // remove the added style rule and all its style attributes
});

I hardly recommend setting the initial style attributes with the css method that you want to animate. You can also set the styles using css between the animate methods.

remove deletes the rule again. After that you can't add new animations to that rule. remove is best called in a callback when the animation is finished (like in the example above). A successful remove returns true. When remove is called while an animation of this rule is still in progress then it is ignored and false is returned.

The remove is optional. You can also use Mass Animate to just set styles without any animations.

Keep in mind that Mass Animate can't animate already set element styles. This is because Mass Animate uses normal style sheet definitions which can't override element styles (!important does not seem to work with jQuery animations).

Credits

Thanks to David Tang and his very nice Javascript Stylesheet rule library JSS. Mass Animate reuses some of his code to setup the CSS rules.

License

Dual licensed under the MIT and GPL licenses: http://www.opensource.org/licenses/mit-license.php http://www.gnu.org/licenses/gpl.html

Copyright(c) 2011 Kai Schlamp