Translate X
$('.box').transition({ x: '90px' });
$('.box').transition({ x: '90px' });
$('.box').transition({ y: '30px' });
$('.box').transition({ x: '200px', y: '20px' });
The following transformations are available. Refer to the README for more information.
$('.box').transition({ rotate: '30deg' });
$('.box').transition({ skewX: '30deg' });
$('.box').transition({ skewY: '30deg' });
$('.box').transition({
skewX: '30deg',
skewY: '-30deg'
});
$('.box').transition({ scale: 1.2 });
$('.box').transition({ scale: [2, 1.5] });
You may rotate using rotateX and rotateY. Using perspective is optional, but it should always come before rotateX/Y.
$('.box').transition({
perspective: '100px',
rotateX: '180deg'
});
$('.box').transition({
perspective: '100px',
rotateY: '180deg'
});
$('.box').transition({
perspective: '100px',
rotate3d: '1, 1, 0, 180deg'
});
$('.box').transition({
opacity: 0,
scale: 1.6
});
$('.box').transition({
marginLeft: '20px',
height: '80px'
});
$.fn.transition(options, [duration], [easing], [callback]);
$.fn.transition works just like $.fn.animate. You can pass a duration, easing, and callback.
$('.box').transition({ x: -100 }, function() {
$(this).transition({ opacity: 0 });
});
$('.box').transition({ opacity: 0 }, 'slow');
$('.box').transition({ opacity: 0 }, 2000);
Simply provide a third parameter to $.fn.transition.
$('.box').transition({ x: 330 }, 500, 'linear');
$('.box').transition({ x: 330 }, 500, 'in');
$('.box').transition({ x: 330 }, 500, 'ease');
$('.box').transition({ x: 330 }, 500, 'out');
$('.box').transition({ x: 330 }, 500, 'in-out');
$('.box').transition({ x: 330 }, 500, 'snap');
$('.box').transition({ x: 330 }, 500, 'cubic-bezier(0,0.9,0.3,1)');
$('.box').transition({ x: -100, delay: 400 });
You can provide easing and duration in the options instead Great for CoffeeScript.
$('.box').transition({
x: '100px',
easing: 'snap',
duration: '2000ms'
});
All units (px, deg, ms, etc) are optional.
$('.box').transition({
x: 100,
duration: 2000,
rotate: 30,
easing: 'snap'
});
jQuery-style relative units are supported. Start your values with either += or -=.
$('.box').transition({
rotate: '+=30deg',
x: '+=30'
});
CSS3 transform properties work with $.fn.css as well.
$('.box').css({
x: '90px',
y: '10px',
rotate: '-10deg'
});
$('.box').css({ transform: 'rotate(40deg)' });
$('.box').css({ rotate: '40deg' });
alert($('.box').css('rotate'));
alert($('.box').css('transform'));
You can provide transformation origins via $.fn.css. The format is “x y”, where x and y are coordinates in the given element.
$('.box').css({ transformOrigin: '10px 10px' });
$('.box').transition({ rotate: 40, scale: 1.2 });
Transit uses jQuery’s effect queue by default, exactly like $.fn.animate. This means that transitions will never run in parallel.
$('.box').
transition({ x: '-40px' }, 250).
transition({ x: '0px' }, 250).
transition({ y: '-40px' }, 250).
transition({ y: '0px' }, 250);
You can chain css and transition together (.css({ .. }).transition({ .. })).
$('.box').
css({ x: '-800px' }).
transition({ x: 0 });
See caniuse.com’s report on CSS transitions. To support Mobile Safari, jQuery Transit uses translate3d and scale3d.
jQuery Transit degrades older browsers by simply not doing the transformations (rotate, scale, etc) while still doing standard CSS (opacity, marginLeft, etc) without any animation.
Delays and durations will be ignored.
If you would like to fallback to classic animation when transitions aren’t supported
(usually not recommended, may be slow):
// Delegate .transition() calls to .animate()
// if the browser can't do CSS transitions.
if (!$.support.transition)
$.fn.transition = $.fn.animate;
// Transit uses the same default as $.fn.animate.
$.fx.speeds._default = 300;
// Default easing is stored in $.cssEase.
$.cssEase._default = 'snap';
Define custom easing aliases in $.cssEase.
$.cssEase['bounce'] = 'cubic-bezier(0,1,0.5,1.3)';
$('.box').transition({ x: 0 }, 500, 'bounce');