8000 GitHub - f2er/jquery.transit at 6748684cd1bd7b28835130a352e092bc11ccc2f6
[go: up one dir, main page]

Skip to content

f2er/jquery.transit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 website for full reference.

Usage

Just include this script after jQuery. Requires jQuery 1.4+.

<script src='jquery.js'></script>
<script src='jquery.transit.js'></script>

Transformations

You can set transformations as you would any CSS property in jQuery. (Note that you cannot $.fn.animate() them, only set them.)

$("#box").css({ scale: 2 });                // Scale up 2x (200%)
$("#box").css({ x: '30px' });               // Move right 30px
$("#box").css({ x: 30 });
$("#box").css({ y: '60px' });               // Move down 30px
$("#box").css({ y: 60 });
$("#box").css({ translate: '60px,30px' });  // Move right 60px, and down 30px
$("#box").css({ rotate: '30deg' });         // Rotate 30 degrees clockwise
$("#box").css({ rotate: 30 });
$("#box").css({ skewX: '30deg' });          // Skew horizontally by 30 degrees
$("#box").css({ skewX: 30 });
$("#box").css({ rotate: '+=30' });          // Relative values are supported
$("#box").css('rotate');                    // Getters are okay, too

Animating

You can animate with CSS3 transitions using $.fn.transition(). It works exactly like $.fn.animate(), except it uses CSS3 transitions.

The syntax is $.transition(options, [duration], [easing], [complete]).

$("#box").transition({ opacity: 0.1, scale: 0.3 });
$("#box").transition({ opacity: 0.1, scale: 0.3 }, 500);                         // duration
$("#box").transition({ opacity: 0.1, scale: 0.3 }, 'fast');                      // easing
$("#box").transition({ opacity: 0.1, scale: 0.3 }, 500, 'in');                   // duration+easing
$("#box").transition({ opacity: 0.1, scale: 0.3 }, function() {..});             // callback
$("#box").transition({ opacity: 0.1, scale: 0.3 }, 500, 'in', function() {..});  // everything

You can also pass duration and easing and complete as values in options, just like in $.fn.animate().

Alternatives

Move.js

  • Pros: no jQuery dependency, great syntax.
  • Cons (at time of writing): no iOS support (doesn't use translate3d), some IE bugs.

jQuery animate enhanced

  • Pros: transparently overrides $.fn.animate() to provide CSS transitions support.
  • Cons: transpalently overrides $.fn.animate(). No transformations support.

jQuery 2D transformations

  • Pros: Tons of transformations.
  • Cons: No CSS transition support; animates via fx.step.

jQuery CSS3 rotate

  • Pros: simply provides rotation.
  • Cons: simply provides rotation. No transitions support.

Acknowledgements

© 2011, Rico Sta. Cruz. Released under the MIT License.

jQuery Transit is authored and maintained by Rico Sta. Cruz with help from it's contributors. It is sponsored by my startup, Sinefunc, Inc.

About

Super-smooth CSS3 transformations and transitions for jQuery

Resources

Stars

Watchers

Forks

Packages

No packages published
0