New Effects Added by jQuery UI


jQuery 1.4 Animation Techniques: Beginners Guide

jQuery 1.4 Animation Techniques: Beginners Guide

Quickly master all of jQuery’s animation methods and build a toolkit of ready-to-use animations using jQuery 1.4

        Read more about this book      

(For more resources related to this subject, see here.)

jQuery UI gives us 14 new predefined animations to use in our pages; these are listed, together with a brief description of their usage, as follows:




The target element is shown or hidden by rolling it down or up like a window blind.


The target element is bounced horizontally or vertically for a specified number of times.


The target element is shown or hidden by moving opposing edges in towards the center of the element, or out to its full width or height.


The element appears to drop onto or off of the page in order to show or hide it respectively.


The explode effect causes the target element to separate into a specified number of pieces before fading away, or to fade into view in several pieces before coming together to form the complete element.


The element appears to fold closed or open.


The background-color of the target element is set (to yellow by default, although this is configurable), and then fades away after a short interval.


The target element increases in size slightly and then fades away.


The target element's opacity is adjusted a specified number of times, making the element appear to flicker on and off.


The dimensions of the target element are adjusted to increase or decrease its size.


The target element is shaken a specified number of times. This effect is similar to the bounce effect with the key difference that the distance of the shake remains the same on each iteration of the animation.


The dimensions of the target element are adjusted to increase or decrease its size. This effect is almost identical to scale.


The target element is made to slide in or out of view, horizontally or vertically.


The outline of the specified element is transferred to another element on the page.

Using the effect API

jQuery UI introduces the effect() method which can be used to trigger any of the effects listed in the previous table. The effect() method's usage pattern is as follows:

jQuery(elements).effect(effect name, [configuration], [duration],

The name of the effect that we would like to use is always the first argument of the effect() method. It is supplied in string format.

Each effect has custom configuration options that can be set to control how the effect displays. These options are set in a configuration object which is passed to the effect() method as the second argument, following the name of the effect.

We can also supply a duration for the effect as an argument. As with standard jQuery animations, we can supply either an integer representing the duration of the effect in milliseconds, or one of the strings slow or fast.

If no configuration is required, the duration may be passed to the effect() method as the second argument. If no duration is supplied, the default duration of 400 milliseconds will be used.

Optionally, a callback function may be provided as the final argument. The supplied function will be executed once for each selected element when the effect ends.

Let's look at the following example of how the effect() method can be used.

The bounce effect

The bounce effect is similar to, but much more controllable than, the easeOutBounce easing function. It can be used with either the effect API or show/hide logic depending on your requirements.

Configuration options

The following configuration options are available for the bounce effect:






The direction of bounce. The other possible option is the string down.



The initial distance of bounce (successive bounces reduce in distance) in pixels.



Whether to run the effect normally or use show/hide logic. Other values accepted may be the strings show, hide, or toggle.



The number of bounces.


In this article we looked at the complete range of new effects which are added by the jQuery UI library. We looked at how they can be used with the effect() method.

Further resources related to this subject:

You've been reading an excerpt of:

jQuery 1.4 Animation Techniques: Beginners Guide

Explore Title