jQuery 1.4 Animation Techniques Beginner's Guide Quickly master all of jQuery's animation methods and build a toolkit of ready-to-use animations using jQuery 1.4 Dan Wellman BIRMINGHAM - MUMBAI jQuery 1.4 Animation Techniques Beginner's Guide Copyright © 2011 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. First published: March 2011 Production Reference: 1140311 Published by Packt Publishing Ltd. 32 Lincoln Road Olton Birmingham, B27 6PA, UK. ISBN 978-1-849513-30-2 www.packtpub.com Cover Image by Filippo ([email protected]) Credits Author Editorial Team Leader Dan Wellman Akshara Aware Reviewers Project Team Leader Shaiful Islam Priya Mukherji Ben Nadel Cyril Pierron Project Coordinator Sneha Harkut Acquisition Editor Sarah Cullington Proofreader Aaron Nash Development Editor Roger D'souza Production Coordinator Melwyn D'sa Technical Editor Conrad Sardinha Cover Work Melwyn D'sa Indexer Hemangini Bari Foreword Since the first jQuery homepage in 2006, an interactive example introduced visitors to jQuery with a single line of code, and a button to run that code. When clicked, it added a class to a hidden paragraph, and animated that paragraph to become visible. Today, in late 2010, the API documentation has 15 methods listed in the Effects category. These provide built-in animations for fading and sliding, as well as various ways to create custom animations. When combined with color and class animations and custom easings that jQuery UI provides, there are even more ways to create animations. A good rule of thumb for using animations is to use slides when showing elements within the pageflow, and fades for overlays, like a tooltip. But that's just a rule of thumb, and with all the tools available there's a lot more opportunity to improve interactions, as well as messing them up. With that in mind, a full book on animations starts to make a lot of sense. It makes even more sense when also taking into account upcoming technologies which aren't bound to jQuery directly, like CSS3 animations or animated canvas drawings. As a tech reviewer I've worked with Dan on his jQuery UI 1.6 and jQuery UI 1.7 books. At the time the jQuery UI team was still figuring out the scope and exact direction of the project, including several direction changes at the time when Dan was writing the first book. Despite these challenges Dan did a great job providing documentation and extensive examples on how to use and combine the widgets and interactions jQuery UI provides. With this book Dan brings his experience in writing on jQuery topics to teach you when and how to use animations to create better user experiences. I hope it serves you well. Jörn Zaefferer jQuery UI development lead, plugin author, and QUnit maintainer About the Author Dan Wellman is an author and web developer based on the South coast of the UK. By day he works alongside some of the most talented people he has had the pleasure of calling colleagues, for a small, yet accomplished digital agency called Design Haus. By night he writes books and tutorials on a range of frontend topics. He is hopelessly addicted to jQuery. His life is enriched by four wonderful children, a beautiful wife, and a close circle of family and friends. This is his fifth book. I would like to thank the hugely supportive and patient editorial team at Packt, without whom this book would not exist. I would also like to thank the reviewers, especially Ben Nadel and Cyril Pierron, who put aside their own personal projects and dedicated countless hours to ensuring the book's technical accuracy. I'd also like to say a big Hey! to some of my closest friends, in no particular order; Andrew Herman, Steev Bishop, Aaron Matheson, Eamon O'Donoghue, James Zabiela, Mike Woodford, and John Adams. About the Reviewers Shaiful Islam completed his graduation in Computer Science and Engineering (CSE) from IIUC (International Islamic University Chittagong), and loves web development and PHP. He is a Software Engineer, with three years of experience in web development and a keen lover of web technology. He also loves CSS, JQuery, CodeIgniter, Cakephp, and Zend Framework, which showed him the way to develop his career in web development and the programming field. His motto is: Work through best approach, commitment, skill, and keep smiling. Currently he is working for "bGlobal Sourcing LLC" as a Software Engineer. I would like to thank all of my friends, colleagues, and those senior brothers who reviewed this type of book before and from whom I got inspiration. Special thanks to everyone at Packt Publishing. Ben Nadel is the chief software engineer at Epicenter Consulting, a Manhattan-based web application development firm specializing in innovative custom software that transforms the way its clients do business. He is also an Adobe Community Professional as well as an Adobe Certified Professional in Advanced ColdFusion. In his spare time, he blogs extensively about all aspects of obsessively thorough web application development at http://www. bennadel.com/. Cyril Pierron is an engineer, a web addict, tech savvy, and life curious. He started programming at age 8, and has been working in telecommunications for the past 12 years. He is married and a father of a lovely baby girl. I would actually like to thank Twitter which gave me the opportunity to see Packt Publishing message when they were looking for reviewers. Obviously thanks to the Packt Publishing team for giving me the chance to work on one of their titles. Lots of thanks to Dan Wellman who I actually followed on Twitter previously to realizing I was reviewing one of his books. This is an amazing piece that draws inspiration and Dan is the most cheerful, open minded, and supportive person. Finally thanks to my wife who showed quite some patience and support when I kept working on this book after hours. www.PacktPub.com Support files, eBooks, discount offers and more You might want to visit www.PacktPub.com for support files and downloads related to your book. Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details. At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks. http://PacktLib.PacktPub.com Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read and search across Packt's entire library of books. Why Subscribe? Fully searchable across every book published by Packt Copy and paste, print and bookmark content On demand and accessible via web browser Free Access for Packt account holders If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access.