jQuery only has two effects by default, however using jquery-ui it is possible to add a number of effects like:
Blind
, Bounce
, Clip
, Drop
, Explode
, Fade
, Fold
, Highlight
, Puff
, Pulsate
, Scale
, Shake
, Size
, Slide
and Transfer
However adding an entire library just to use part of it may be unnecessary.
jQuery is an extensible framework or supports adding functionality to existing events, for example:
$.fx.step['size'] = function(fx)
{
if ( !fx._sizeInit )
{
var $el = $(fx.elem),
c = fx.end.center || {top: 0, left: 0};
fx.start = $el.offset();
$.extend(fx.start, {width: $el.width(), height: $el.height()});
fx._sizer = {};
fx._sizer.topDelta = c.top - (c.top * fx.end.height / fx.start.height);
fx._sizer.leftDelta = c.left - (c.left * fx.end.width / fx.start.width);
fx._sizer.widthDelta = fx.end.width - fx.start.width;
fx._sizer.heightDelta = fx.end.height - fx.start.height;
fx._sizeInit = true;
}
fx.elem.style.top = fx.start.top + Math.floor(fx._sizer.topDelta * fx.pos) + 'px';
fx.elem.style.left = fx.start.left + Math.floor(fx._sizer.leftDelta * fx.pos) + 'px';
fx.elem.style.width = fx.start.width + Math.floor(fx._sizer.widthDelta * fx.pos) + 'px';
fx.elem.style.height = fx.start.height + Math.floor(fx._sizer.heightDelta * fx.pos) + 'px';
};
The use would be:
$('myDiv')
.animate({
size: {
center: {top: 0, left: 30},
height: 100,
width: 200
}
}, 'slow');
Source: http://www.benknowscode.com/2012/09/extending-jquery-animate-beyond-basic_6504.html
View a library https://github.com/benignware/jquery.fx-transition which supports various effects such as:
- swing, linear, ease, easeIn, easeInQuad, easeInCubic, easeInQuart, easeInQuint, easeInSine, easeInExpo, easeInCirc, easeInBack, easeOut, easeOutQuad, easeOutCubic, easeOutQuart, easeOutQuint, easeOutSine, easeOutExpo, easeOutCirc, easeOutBack, easeInOut, easeInOutQuad, easeInOutCubic, easeInOutQuart, easeInOutQuint, easeInOutSine, easeInOutExpo, easeInOutCirc, easeInOutBack
Take the file https://github.com/benignware/jquery.fx-transition/blob/master/dist/jquery.fx-transition.min.js (weighs on average ~7kb much lighter than jquery-ui) and next to jquery, so:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Exemplo</title>
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="../dist/jquery.fx-transition.js"></script>
</head>
Detail better your doubt.
– rubStackOverflow
concegui to make the effect with fadein and fadeOut, but there are other effects?
– brunoangola