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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

[ 149 ]<br />

Chapter 6<br />

In the previous screenshot, we see the text fields being shaken when they are left empty and<br />

the is clicked.<br />

What just happened?<br />

When the is clicked we simply check to see if each has a value and<br />

if not, we apply a red border and then call the effect() method specifying shake as the<br />

effect. We use a configuration object to reduce the distance the element moves, as well as<br />

specifying a relatively short duration.<br />

The size effect<br />

The size effect is used to resize an element, making it grow or shrink depending on its<br />

configuration. Unlike most <strong>of</strong> the other effects, the size effect must be configured for it<br />

to be used successfully.<br />

The size effect is also one <strong>of</strong> the only effects that has the base core file as well as another<br />

effect as dependencies. Most components rely only on the core file. As we downloaded<br />

the entire effect suite from the <strong>jQuery</strong> UI download builder, we don't need to worry about<br />

including the additional effect. It's already in the single file that the download builder<br />

created when we downloaded it at the start <strong>of</strong> the chapter.<br />

Configuration options<br />

The size effect gives us four configurable options, which are listed as follows:<br />

Option Default Usage<br />

from none Sets the size <strong>of</strong> the target element at the beginning <strong>of</strong> the<br />

animation. This option accepts an object with height and<br />

width keys which are used to set the starting size <strong>of</strong> the target<br />

element. This option is not mandatory.<br />

to none Sets the size <strong>of</strong> the target element at the end <strong>of</strong> the animation.<br />

This option accepts an object with height and width keys<br />

which are used to set the ending size <strong>of</strong> the target element. This<br />

option must be supplied.<br />

origin ['middle ',<br />

'center']<br />

Sets the vanishing point for hiding animations, or the point from<br />

which it grows when used with show logic.<br />

scale "both " This option sets whether the whole box <strong>of</strong> the element<br />

(including border and padding CSS values) is scaled, just the<br />

content, or as in the default, both.

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

Saved successfully!

Ooh no, something went wrong!