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.

Extended <strong>Animation</strong>s with <strong>jQuery</strong> UI<br />

Configuration options<br />

The drop effect allows us to control the direction that the element drops, and whether it is<br />

shown or hidden:<br />

Option Default Usage<br />

direction "left" Sets the direction that the element drops in or out <strong>of</strong> the page.<br />

The other option is the string right.<br />

mode "hide" Sets whether the element is shown or hidden when using the<br />

effect() method. Other possible values include show,<br />

toggle, and effect.<br />

Time for action – using the effect<br />

The social networking site Twitter introduced a novel effect whereby the system reports<br />

actions to the visitor by displaying a message that drops down at the top <strong>of</strong> the page.<br />

We can easily replicate this behavior using the drop effect.<br />

1. Add the following markup to the <strong>of</strong> our template page:<br />

<br />

Your request has been completed!<br />

<br />

2. Now at the bottom <strong>of</strong> the page add the following code:<br />

$("#confirmation").effect("drop", {<br />

mode: "show",<br />

direction: "up"<br />

}, function() {<br />

var timer = function() {<br />

$("#confirmation").effect("drop", { mode: "hide", direction:<br />

"up"});<br />

}<br />

setTimeout(function() { timer() }, 3000);<br />

});<br />

3. Save the page as drop.html. We only need a few styles for this example. Create<br />

the following very basic stylesheet:<br />

body { background-color:#3cf; }<br />

#confirmation {<br />

display:none width:100%; height:60px; position:absolute; top:0;<br />

left:0; z-index:999; background-color:#fff; text-align:center;<br />

font:normal 18px "Nimbus Sans L", "Helvetica Neue", "Franklin<br />

[ 160 ]

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

Saved successfully!

Ooh no, something went wrong!