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.

[ 155 ]<br />

Chapter 6<br />

In the configuration object, we set the to option to a selector for the apps element, and<br />

the className option to the string ui-effect-transfer. This string is applied to the<br />

element as a class name and is used to add a green border to the transfer element while<br />

it is visible.<br />

Each time the is clicked, the transfer element will be shown and will animate<br />

from the starting element (the Firefox icon) to the ending element (the Apps folder icon).<br />

Pop quiz – using the effect API<br />

1. How many new effects does <strong>jQuery</strong> UI give us?<br />

a. 2<br />

b. 18<br />

c. 9<br />

d. 14<br />

2. How is the effect we wish to use specified?<br />

a. By calling the effect as a function, for example bounce()<br />

b. The name <strong>of</strong> the effect is passed in string format to the effect() method<br />

as the first argument, for example effect("bounce")<br />

c. The name <strong>of</strong> the effect is provided as the value <strong>of</strong> the effect key in an<br />

object passed to the animate() method, for example animate({ effect:<br />

"bounce" })<br />

d. The name <strong>of</strong> the effect is passed as a string to an event helper, for example<br />

click("bounce")<br />

Using effects with show and hide logic<br />

Some <strong>of</strong> the <strong>jQuery</strong> UI effects can also be used in conjunction with <strong>jQuery</strong>'s show(),<br />

hide(), and toggle() methods when showing or hiding logic is required. In fact,<br />

some <strong>of</strong> the effects are better suited to this method <strong>of</strong> execution.<br />

The blind effect<br />

The blind effect is the perfect example <strong>of</strong> an effect that is usually best used with show/hide<br />

logic as opposed to the standard effect API. Although the blind effect will work with the<br />

standard effect API, what will happen is that the effect will run according to its default mode,<br />

but then the element will be put back into its original state. This is true for all effects that<br />

have a mode configuration option.

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

Saved successfully!

Ooh no, something went wrong!