02.06.2013 Views

jQuery 1.4 Animation Techniques - Index of

jQuery 1.4 Animation Techniques - Index of

jQuery 1.4 Animation Techniques - Index of

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

2. What else can be passed into the method?<br />

[ 27 ]<br />

Chapter 2<br />

a. A string specifying the easing function to use for the animation, and a callback<br />

function to be executed once the animation ends<br />

b. An object containing additional configuration options<br />

c. An array containing additional configuration options<br />

d. A callback function to be executed at the start <strong>of</strong> an animation and a callback<br />

function to be executed at the end <strong>of</strong> the animation<br />

Have a go hero – doing more with fadeIn<br />

In this example, we used the fadeIn() method to show the hidden elements on<br />

mouseover, but hide the element straight away on mouseout. Have a go at extending the<br />

example so that the elements are faded out on mouseout instead <strong>of</strong> being hidden straight<br />

away using the fadeOut() method.<br />

Fading elements out<br />

The fadeOut() method is syntactically identical to fadeIn() in that it accepts the same<br />

arguments and adjusts the opacity <strong>of</strong> the selected element, except that with the fadeout()<br />

method, the target element is hidden instead <strong>of</strong> being shown. Let's look at this method in<br />

action with a brief example.<br />

When elements need to be removed from the page, using a subtle fade out can be much<br />

more effective than just removing the element in question. We may have an overlay <strong>of</strong> some<br />

description, like a dialog box for example, on the page which can be closed by the visitor.<br />

Instead <strong>of</strong> having it disappear instantly, we can animate its disappearance smoothly.<br />

In this example, we'll look at the following aspects <strong>of</strong> using fadeOut():<br />

Hiding an element with the fadeOut() method<br />

Using a numerical argument to control the duration<br />

Running additional code once the animation completes

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!