Super-smooth CSS3 transformations and transitions for jQuery

Overview

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+.

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

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.)

$("#box").css({ x: '30px' });               // Move right
$("#box").css({ y: '60px' });               // Move down
$("#box").css({ translate: [60,30] });      // Move right and down
$("#box").css({ rotate: '30deg' });         // Rotate clockwise
$("#box").css({ scale: 2 });                // Scale up 2x (200%)
$("#box").css({ scale: [2, 1.5] });         // Scale horiz and vertical
$("#box").css({ skewX: '30deg' });          // Skew horizontally
$("#box").css({ skewY: '30deg' });          // Skew vertical
$("#box").css({ perspective: 100, rotateX: 30 }); // Webkit 3d rotation
$("#box").css({ rotateY: 30 });
$("#box").css({ rotate3d: [1, 1, 0, 45] });

Relative values are supported.

$("#box").css({ rotate: '+=30' });          // 30 degrees more
$("#box").css({ rotate: '-=30' });          // 30 degrees less

All units are optional.

$("#box").css({ x: '30px' });
$("#box").css({ x: 30 });

Multiple arguments can be commas or an array.

$("#box").css({ translate: [60,30] });
$("#box").css({ translate: ['60px','30px'] });
$("#box").css({ translate: '60px,30px' });

Getters are supported. (Getting properties with multiple arguments returns arrays.)

$("#box").css('rotate');     //=> "30deg"
$("#box").css('translate');  //=> ['60px', '30px']

Animating - $.fn.transition

$('...').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.

$("#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().

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

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.

Move.js

  • 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.

jQuery animate enhanced

  • Pros: transparently overrides $.fn.animate() to provide CSS transitions support.
  • Cons: transparently 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.

Support

Bugs and requests: submit them through the project's issues tracker.
Issues

Questions: ask them at StackOverflow with the tag jquery-transit.
StackOverflow

Chat: join us at gitter.im.
![Chat](http://img.shields.io/badge/gitter-rstacruz / jquery.transit-brightgreen.svg)

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

npm version

Comments
  • Can not stop a current animation

    Can not stop a current animation

    Is it possible to stop an animation? Right now, when I use $('element').transition(x, y) the animation needs to be completed before I can manipulate the x/y etc..

    Hope you have a solution for this.

    Thanks in advance!

    Cheers, Patrick

    opened by inlet 33
  • BUG: Error when calling .transition() in IE 10

    BUG: Error when calling .transition() in IE 10

    When using IE 10 and calling this function:

    $(this).transition({
      scale:            1.05,
      backgroundColor:  "#8EC3DA",
      borderColor:      "#686868",
      duration:         150
    });
    
    

    I receive this error message:

    SCRIPT438: Object doesn't support property or method 'setFromString' 
    jquery.transit.js, line 598 character 9
    

    Here's a screenshot:

    As of writing, you can see the error in action at http://ryansobol.com by mousing over any of the social buttons.

    NOTE: Everything works fine in IE 9, Chrome 19, Firefox 13, and Safari 5.1.

    PS - I'm in love with this library. Keep up the great work!

    opened by ryansobol 16
  • Option to disable the queue

    Option to disable the queue

    It would be nice to have the option to avoid the queue and apply the transform immediately. Currently, if I want a responsive animation for my slider widget, I have to use use a css transform, which feels wrong :/ (especially since transition requires a vendor prefix).

    var transition = 'all ' + duration + 'ms ' + easing;
    slider.css({ 
      transform: 'translate(' + sliderOffset + 'px, 0, 0)', 
      'transition': transition,
      '-webkit-transition': transition,
      '-moz-transition': transition,
      '-ms-transition': transition,
      '-o-transition': transition
    });
    
    opened by dsego 10
  • Transitionend event name detection

    Transitionend event name detection

    This should be fine or you can make your own version based on it. I've tried to keep the code as DRY as possible. Warning: based on the MDN docs this is very likely to fail on Safari >= 3.0 && < 3.2. I believe only browser sniffing trickery is the only way to avoid this, which should be redundant considering the market share of those versions.

    About the event names:

    • transitionEnd doesn't exist
    • there is no MSTransitionEnd or even if there is, IE supports the w3c name
    • opera has 2 differently cased event names

    Adding the proper event name to $.support would need a Deferred object and be relatively useless.

    Thanks.

    References used:

    • https://developer.mozilla.org/en-US/docs/Web/Reference/Events/transitionend
    • https://developer.mozilla.org/en-US/docs/Web/CSS/transition
    • http://msdn.microsoft.com/en-us/library/ie/hh673535%28v=vs.85%29.aspx
    opened by csimi 9
  • Fix for jQuery 1.8

    Fix for jQuery 1.8

    jQuery 1.8 was released today, which includes a feature that causes .css(...) to automatically prefix webkit-specific stuff, like transform. Since transit stores its Transform() object in the elem.css("transform"), this was conflicting. It is now stored in transit:transform, and seems to be working great.

    opened by cheald 9
  • Transform code stops working at random

    Transform code stops working at random

    Okay, I admit that this going to sound vague but I've narrowed it down every way I can and I think there is a good chance jquery.transit is the reason for this issue (although I'm not 100% sure). Let my describe the issue:

    I have jquery.transit running transform origin and rotate on mouseover of an image - so it can happen multiple times in a row. It always works on the first mouseover but does not work for an infinite amount of times: it stops working eventually - maybe on the second mouseover, maybe on the 20th.

    There seems to be almost no pattern as to when it breaks:

    • after working at least once (never breaks the first time) and as many as 10 or 15 times, the rotate command stops working
    • BUT the javascript is NOT breaking because other commands (for example, an .animate() event runs just fine before and after rotate stops working). I verified that js is not breaking with a try catch.
    • I can almost certainly reproduce the issue but never in a set pattern
    • Depending on what part of the image you mouseover you trigger a different rotate angle and it does seem to break more often when rotating a negative degree - but breaks on other rotate angles as well.

    I know this is a long shot but I really like jquery.transit and I was wondering if anyone else has seen this problem? I realize its possible this bug has to do with CSS3 transform or rotate, but I've done a lot of searching and I can't find this problem reported on at all in forums, etc.

    My code is in development at the link below, maybe it will make the above description more clear:

    http://www.markpruce.com/8ozstudios/

    Any debugging advice or help on this would be greatly appreciated! Thanks,

    Mark

    opened by 8ozStudios 9
  • Percentage based transitions issue

    Percentage based transitions issue

    I'm working on a responsive navigation that uses percentage based values for layout. This plugins seems to do its job with pixel values, but when it comes to percentages (and possibly other units) it breaks.

    The following transition gets converted into 100 pixels by the plugin.

    productNavigation.transition({ : "+=100%"...

    opened by ghost 8
  • FF 16 TypeError

    FF 16 TypeError

    worked in FF 15 but after updating to FF 16 I get the following error:

    TypeError: h.setFromString is not a function

    ...ion(b){return(d(b).css("transform")||new j).get(a)},set:function(b,e){var h=d(b)...

    here is the website: http://www.autobusoberbayern.de/de/startseite/

    opened by markusfalk 8
  • Error: TypeError: t.setFromString is not a function

    Error: TypeError: t.setFromString is not a function

    Using the following, with jquery 1.8, I always get one of two errors:

    $('#carousel ul').css({ x: '30px' });

    Using the source:

    Error: TypeError: t.setFromString is not a function

    or using the minified version:

    Error: TypeError: h.setFromString is not a function

    Any idea what could be causing this??

    thanks!

    opened by jesserosenfield 8
  • Fix for JQuery 1.8.0

    Fix for JQuery 1.8.0

    The other suggested solution (https://github.com/rstacruz/jquery.transit/pull/62) didn't work for me. This got all of my transitions working correctly.

    opened by scien 8
  • CSS Filters not supported

    CSS Filters not supported

    e.g.

    $('#thing').transition({
        '-webkit-filter': 'blur(4px)',
        '-moz-filter': 'blur(4px)',
        '-ms-filter': 'blur(4px)',
        '-o-filter': 'blur(4px)',
        'filter': 'blur(4px)'
        }, 400, 'in-out', function(){...
    

    It'll work, but it won't transition. I tried both blur(0px) as well as none.

    Great work by the way! Love the plugin.

    Help wanted 
    opened by iest 7
  • No simultaneous transitions on an element?

    No simultaneous transitions on an element?

    Simultaneous transitions on a single element don't seem to work if using multiple calls to $.transit(). For example:

    $w.transit( {opacity: 0.3, queue: false, duration:1500} );
    $w.transit( {scale:   0.5, queue: false, duration:1200} );
    

    Only scale is animated; opacity jumps immediately from its current value to 0.3.

    Thus it seems impossible with jquery.transit to animate two different css properties of an object at the same time, if the transitions have different durations or delays (or if you have other reasons to want to separate the animations into distinct calls to $.transit().

    opened by mblais 2
  • Add support for *skew*.

    Add support for *skew*.

    This PR adds support for skew transform, in no more than 10 lines of code.

    The transforms skewX and skewY were already supported in current version. However, skew cannot be replaced with them (perhaps there is a way to make such replacement but seems hard to do so).

    We may try the following snippets, which lead to different styles:

    • transform skew(45deg, 45deg)
    • transform skewX(45deg) skewY(45deg)
    • transform skewY(45deg) skewX(45deg)
    opened by 0x10001 0
  • Error: Cannot read property 'speeds' of undefined when omitting duration

    Error: Cannot read property 'speeds' of undefined when omitting duration

    Hello,

    Ive installed jquery.transit over npm and when calling the transition method on any element I get the following error:

    > temp1.transition({x: 100})
    
    Uncaught TypeError: Cannot read property 'speeds' of undefined
        at r.fn.init.$.fn.transition.$.fn.transit (jquery.transit.js:603)
        at <anonymous>:1:7
    

    When adding the duration temp1.transition({x: 100}, 300) it works fine.

    opened by crtl 1
  • Is this project dead?

    Is this project dead?

    I've been using AnimeJS however it doesn't have a way of returning a value or applying a value without a delay.

    These are two I need for the current project I have. Transform properties are a nightmare unless using something like this. I can't find anything that replaces this, however bugs such as not being able to get scale() it always returns 1 regardless is meaning I can't use it.

    Is this dead? Can I fork it and start from where you left off?

    opened by TomS- 3
A simple and easy jQuery plugin for CSS animated page transitions.

Animsition A simple and easy jQuery plugin for CSS animated page transitions. Demo & Installation http://git.blivesta.com/animsition/ Development Inst

Yasuyuki Enomoto 3.8k Dec 17, 2022
Unobtrusive page transitions with jQuery.

smoothState.js smoothState.js is a jQuery plugin that progressively enhances page loads to give us control over page transitions. If the user's browse

Miguel Pérez 4.5k Dec 21, 2022
A jquery plugin for CSS3 text animations.

Textillate.js v0.4.1 See a live demo here. Textillate.js combines some awesome libraries to provide an easy-to-use plugin for applying CSS3 animations

Jordan Schroter 3.6k Jan 2, 2023
Create beautiful CSS3 powered animations in no time.

Bounce.js Bounce.js is a tool and JS library for generating beautiful CSS3 powered keyframe animations. The tool on bouncejs.com allows you to generat

Tictail 6.2k Dec 30, 2022
CSS3 backed JavaScript animation framework

Move.js CSS3 JavaScript animation framework. About Move.js is a small JavaScript library making CSS3 backed animation extremely simple and elegant. Be

Sloth 4.7k Dec 30, 2022
🐿 Super easy and lightweight(<3kb) JavaScript animation library

Overview AniX - A super easy and lightweight javascript animation library. AniX is a lightweight and easy-to-use animation library with excellent perf

anonymous namespace 256 Sep 19, 2022
Matteo Bruni 4.7k Jan 4, 2023
A jQuery plugin that assists scrolling and snaps to sections.

jQuery Scrollify A jQuery plugin that assists scrolling and snaps to sections. Touch optimised. Demo http://projects.lukehaas.me/scrollify. More examp

Luke Haas 1.8k Dec 29, 2022
Slide-element - A ~700 byte Promise-based library for animating elements with dynamic heights open & closed. Basically, a modern variant of jQuery's slideUp(), slideDown(), and slideToggle().

slide-element A tiny, accessible, Promise-based, jQuery-reminiscent library for sliding elements with dynamic heights open & closed. To see it in acti

Alex MacArthur 165 Dec 12, 2022
fakeLoader.js is a lightweight jQuery plugin that helps you create an animated spinner with a fullscreen loading mask to simulate the page preloading effect.

What is fakeLoader.js fakeLoader.js is a lightweight jQuery plugin that helps you create an animated spinner with a fullscreen loading mask to simulat

João Pereira 721 Dec 6, 2022
A jQuery plugin that recreates the Material Design pre-loader (as seen on inbox).

Material Design Preloader!s A jQuery plugin that recreates the Material Design preloader (as seen on inbox). I was fascinated when I first saw the pre

Aaron Lumsden 376 Dec 29, 2022
Simple parallax scrolling effect inspired by Spotify.com implemented as a jQuery plugin

Parallax.js Simple parallax scrolling implemented as a jQuery plugin. http://pixelcog.com/parallax.js/ Please also check our v2.0.0-alpha! We'd be hap

PixelCog Inc. 3.5k Dec 21, 2022
Lightweight, simple to use jQuery plugin to animate SVG paths

jQuery DrawSVG This plugin uses the jQuery built-in animation engine to transition the stroke on every <path> inside the selected <svg> element, using

Leonardo Santos 762 Dec 20, 2022
Responsive, interactive and more accessible HTML5 canvas elements. Scrawl-canvas is a JavaScript library designed to make using the HTML5 canvas element a bit easier, and a bit more fun!

Scrawl-canvas Library Version: 8.5.2 - 11 Mar 2021 Scrawl-canvas website: scrawl-v8.rikweb.org.uk. Do you want to contribute? I've been developing thi

Rik Roots 227 Dec 31, 2022
Animator Core is the runtime and rendering engine for Haiku Animator and the components you create with Animator

Animator Core is the runtime and rendering engine for Haiku Animator and the components you create with Animator. This engine is a dependency for any Haiku Animator components that are run on the web.

Haiku 757 Nov 27, 2022
Javascript and SVG odometer effect library with motion blur

SVG library for transitioning numbers with motion blur JavaScript odometer or slot machine effect library for smoothly transitioning numbers with moti

Mike Skowronek 793 Dec 27, 2022
:dizzy: TransitionEnd is an agnostic and cross-browser library to work with transitionend event.

TransitionEnd TransitionEnd is an agnostic and cross-browser library to work with event transitionend. Browser Support 1.0+ ✔ 4.0+ ✔ 10+ ✔ 10.5 ✔ 3.2+

Evandro Leopoldino Gonçalves 95 Dec 21, 2022
fullPage plugin by Alvaro Trigo. Create full screen pages fast and simple

fullPage.js English | Español | Français | Pусский | 中文 | 한국어 Available for Vue, React and Angular. | 7Kb gziped | Created by @imac2 Demo online | Cod

Álvaro 34.3k Dec 30, 2022
Slickscroll - A Lightweight JavaScript library for quick and painless momentum & parallax scrolling effects.

Slickscroll is a JavaScript library that makes momentum & parallax scrolling quick and painless View Demo: slickscroll.musabhassan.com Momentum Scroll

Musab Hassan 33 Dec 28, 2022