Book Image

Mastering jQuery

By : Alex Libby
Book Image

Mastering jQuery

By: Alex Libby

Overview of this book

<p>Mastering jQuery has been written not only to help maximize your skills with core functionality in the library, but also to explore some of the more intriguing ways of using the library to achieve real-world solutions that could feature on any website or online environment.</p> <p>You'll start with a look at some of the more advanced ways to incorporate the library into your pages, followed by working with forms and advanced form validation using regular expressions. Next you'll move on to animating in jQuery, advanced event handling, and using jQuery effects.</p> <p>Finally, you will develop practical examples of using jQuery with external functionality such as node-webkit, before finishing with a session on optimizing your version of the library for maximum efficiency and exploring best practices for using QUnit.</p>
Table of Contents (21 chapters)
Mastering jQuery
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Creating and managing the effect queue


Queues, queues – who likes queuing, I wonder?

Although not all of us like to queue for things, such as for getting lunch or visiting a bank, queuing is critical to the success of running animations. It matters not one jot if we're using .slideUp(), .animate() or even .hide() – if we chain too many animations, we will hit a point where animations won't run.

To release the animation, we need to explicitly call .dequeue(), as the methods come in pairs. Consider the following example for a moment, taken from http://cdmckay.org/blog/2010/06/22/how-to-use-custom-jquery-animation-queues/:

Imagine you're making a game and you want to have an object start at top:100px, then float upwards for 2000 milliseconds. Furthermore, you would like the said object to stay completely opaque for 1000 milliseconds before slowly becoming completely transparent over the remaining 1000 milliseconds:

Time (in ms)

Top

Opacity

0

100px

1.0

500

90px

1.0

1000

80px

1.0

1500...