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.

[ 63 ]<br />

Chapter 3<br />

The argument we supply to the function passed into the queue() method is called next.<br />

<strong>jQuery</strong> will treat whatever we pass in as a function and all we have to do is call this function<br />

from within the callback function and that will make sure the next function in the queue<br />

is executed.<br />

The function we pass into the callback function passed to the queue() method doesn't have<br />

to be identified as next, it can be any accepted function name. In this example, we call the<br />

next function after setting the background-color <strong>of</strong> the to green.<br />

This will cause the extra fadeout() method to be executed last, so when we run this<br />

example in a browser, we should find that the green disappears at the end.<br />

Pop quiz – keeping the queue running<br />

1. What can we use to call the next function in the queue when inserting a callback<br />

function into the queue using the queue() method?<br />

a. A Boolean value <strong>of</strong> true passed into the callback function as an argument<br />

b. A string containing the word next<br />

c. A function<br />

d. An integer <strong>of</strong> -1<br />

Replacing the queue<br />

Sometimes adding a single function to the end <strong>of</strong> the queue may not be enough—we<br />

may wish to replace the queue entirely. This behavior is also managed entirely by the<br />

queue() method.<br />

Time for action – replacing the queue<br />

1. We'll update the queue.html file once again for this example. We'll need another<br />

style rule in the element in the <strong>of</strong> the page:<br />

#fader span {<br />

display:none; width:100%; height:100%; position:absolute;<br />

left:0;<br />

top:0;<br />

}<br />

2. We should also add position:relative; to the #fader selector.

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

Saved successfully!

Ooh no, something went wrong!