jQuery Transit
Super-smooth CSS3 transformations and transitions for jQuery
jQuery Transit is a plugin for to help you do CSS transformations and transitions in jQuery.
Refer to the jQuery Transit website for examples.
Usage
Just include jquery.transit.js after jQuery. Requires jQuery 1.4+.
It is also available via bower and npm.
$ bower install --save jquery.transit
$ npm install --save jquery.transit
Transformations
You can set transformations as you would any CSS property in jQuery.
(Note that you cannot $.fn.animate()
them, only set them.)
; // Move right; // Move down; // Move right and down; // Rotate clockwise; // Scale up 2x (200%); // Scale horiz and vertical; // Skew horizontally; // Skew vertical; // Webkit 3d rotation;;
Relative values are supported.
; // 30 degrees more; // 30 degrees less
All units are optional.
;;
Multiple arguments can be commas or an array.
;;;
Getters are supported. (Getting properties with multiple arguments returns arrays.)
; //=> "30deg"; //=> ['60px', '30px']
$.fn.transition
Animating - $('...').transition(options, [duration], [easing], [complete])
You can animate with CSS3 transitions using $.fn.transition()
. It works
exactly like $.fn.animate()
, except it uses CSS3 transitions.
;; // duration; // easing; // duration+easing; // callback; // everything
You can also pass duration and easing and complete as values in options
, just like in $.fn.animate()
.
;
Tests
Transit has a unique test suite. Open test/index.html
to see it. When
contibuting fixes, be sure to test this out with different jQuery versions and
different browsers.
Alternatives
Velocity.js (recommended!)
- Pros: optimized for situations with hundreds of simultaneous transitions. Lots of extra features.
- Pros: no jQuery dependency, great syntax.
- Cons (at time of writing): no iOS support (doesn't use
translate3d
), some IE bugs, no 3D transforms, no animation queue.
- Pros: transparently overrides
$.fn.animate()
to provide CSS transitions support. - Cons: transparently overrides
$.fn.animate()
. No transformations support.
- Pros: Tons of transformations.
- Cons: No CSS transition support; animates via
fx.step
.
- Pros: simply provides rotation.
- Cons: simply provides rotation. No transitions support.
Support
Bugs and requests: submit them through the project's issues tracker.
Questions: ask them at StackOverflow with the tag jquery-transit.
Thanks
jQuery Transit © 2011-2014+, Rico Sta. Cruz. Released under the MIT License.
Authored and maintained by Rico Sta. Cruz with help from contributors.
ricostacruz.com · GitHub @rstacruz · Twitter @rstacruz