jQuery only has two effects by default, however using jquery-ui it is possible to add a series of effects like:
Blind
, Bounce
, Clip
, Drop
, Explode
, Fade
, Fold
, Highlight
, Puff
, Pulsate
, Scale
and Shake
However adding a whole library just to use part of it may be unnecessary.
jQuery is an extensible framework that allows you to add 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: link
View a library link that supports various effects like:
- swing, linear, ease, easeInQuad, easeInCubic, easeInQuint, easeInQuint, easeInSim, easeInExpo, easeInCirc, easeInBack, easeInBack, easeOutQuad, easeOutCubic, easeOutCubic, easeOutQuit, easeOutQuint, easeOutSim, easeOutExpo, easeOutCirc, easeOutBack, easeInOut, easeInOutQuad, easeInOutCubic , easeInOutQuit, easeInOutQuint, easeInOutSine, easeInOutExpo, easeInOutCirc, easeInOutBack
Take the link file ( it weighs on average ~ 7kb much lighter than jquery-ui) and next to jquery, like this:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Exemplo</title>
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script><scriptsrc="../dist/jquery.fx-transition.js"></script>
</head>