jQuery 1.4 Animation Techniques Beginner's Guide
By Dan Wellman
()
About this ebook
jQuery is a cross-browser JavaScript library designed to simplify the client-side scripting of HTML, and is the most popular JavaScript library in use today. Using the features offered by jQuery, developers are able to create dynamic web pages. This book will act as a resource for you to create animation and advanced special effects in your web applications, by following the easy-to-understand steps mentioned in it.
jQuery 1.4 Animation Techniques: Beginners Guide will allow you to master animation in jQuery to produce slick and attractive interfaces that respond to your visitors' interactions. You will learn everything you need to know about creating engaging and effective web page animations using jQuery. The book uses many examples and explains how to create animations using an easy, step-by-step, beginners guide approach.
This book will provide you with...This book provides various examples that gradually build up the reader's knowledge and practical experience in using the jQuery API to create stunning animations. The book starts off by explaining how animations make your user interface interactive and attractive. It explains the various methods used to make the element being animated appear or disappear. It provides a set of steps to create simple animations and show fading animations.
You can later learn how to make complex animations by chaining different effects together as well as how to halt a currently running application. You will find out how to slide your animation elements and learn to create custom animations that can be complex and specialized.
You will find out how to obtain and set up the jQuery UI- the official user interface library for jQuery. The book will tell you how to animate a page's background image, and will teach you how to make images scroll in a certain direction and at a certain speed depending on the movement of the mouse pointer
This book and eBook will enable you to learn how to create engaging and interactive user interfaces, and attractive special effects using jQuery
ApproachAll the concepts in the book are explained in a simple, easy to understand, step-by-step manner. There are plenty of examples and images used in this book, with the images properly explained. Written with a friendly and engaging approach, this Packt Beginner's guide is designed to be placed alongside the computer as your guide and mentor to create attractive web page animations using jQuery.
Who this book is forThis book is written for web designers and front-end developers who already have good knowledge of HTML and CSS, and some experience with jQuery. If you want to learn how to animate the user interface of your web applications with jQuery, then this book is for you.
Dan Wellman
Dan Wellman is an author and frontend engineer living on the south coast of the UK and working in London. By day he works for Skype and has a blast writing application-grade JavaScript. By night he writes books and tutorials focused mainly on frontend web development. He is also a staff writer for the tuts+ arm of the Envato network, and occasionally writes for .Net magazine. He's the proud father of four amazing children, and the grateful husband of a wonderful wife.
Read more from Dan Wellman
jQuery Hotshot Rating: 0 out of 5 stars0 ratingsjQuery UI 1.7: The User Interface Library for jQuery Rating: 0 out of 5 stars0 ratingsjQuery UI 1.10: The User Interface Library for jQuery Rating: 0 out of 5 stars0 ratingsYUI 2.8: Learning the Library Rating: 4 out of 5 stars4/5jQuery 2.0 Animation Techniques Beginner's Guide Rating: 0 out of 5 stars0 ratings
Related to jQuery 1.4 Animation Techniques Beginner's Guide
Related ebooks
Mastering Ext JS - Second Edition Rating: 0 out of 5 stars0 ratingsAngularJS Web Application Development Cookbook Rating: 0 out of 5 stars0 ratingsASP.NET jQuery Cookbook - Second Edition Rating: 0 out of 5 stars0 ratingsMastering jQuery UI Rating: 0 out of 5 stars0 ratingsSocial Media for WordPress Beginner's Guide Rating: 0 out of 5 stars0 ratingsjQuery for Designers Beginner's Guide Second Edition Rating: 5 out of 5 stars5/5PhpStorm Cookbook Rating: 0 out of 5 stars0 ratingsLiveCode Mobile Development Beginner's Guide Rating: 0 out of 5 stars0 ratingsMeteor Cookbook Rating: 5 out of 5 stars5/5Flash with Drupal Rating: 0 out of 5 stars0 ratingsPHP Ajax Cookbook Rating: 2 out of 5 stars2/5phpBB: A User Guide Rating: 0 out of 5 stars0 ratingsPHP and MongoDB Web Development Beginner’s Guide Rating: 0 out of 5 stars0 ratingsWordPress Mobile Web Development: Beginner's Guide Rating: 0 out of 5 stars0 ratingsjQuery for Designers Beginner's Guide Rating: 5 out of 5 stars5/5Responsive Web Design by Example : Beginner's Guide - Second Edition Rating: 0 out of 5 stars0 ratingsNode.js 6.x Blueprints Rating: 0 out of 5 stars0 ratingsWordPress 3.0 jQuery Rating: 0 out of 5 stars0 ratingsFlash Development for Android Cookbook Rating: 3 out of 5 stars3/5Meteor: Full-Stack Web Application Development Rating: 0 out of 5 stars0 ratingsLearning Dart Rating: 0 out of 5 stars0 ratingsHeroku Cookbook Rating: 0 out of 5 stars0 ratingsLearn PHP 8: Using MySQL, JavaScript, CSS3, and HTML5 Rating: 0 out of 5 stars0 ratingsjQuery Mobile Web Development Essentials - Third Edition Rating: 0 out of 5 stars0 ratingsjQuery Design Patterns Rating: 0 out of 5 stars0 ratingsLearning Heroku Postgres Rating: 0 out of 5 stars0 ratingsJavaScript Mobile Application Development Rating: 0 out of 5 stars0 ratingsWordPress 3 Plugin Development Essentials Rating: 4 out of 5 stars4/5Libgdx Cross-platform Game Development Cookbook Rating: 0 out of 5 stars0 ratingsModern CSS: Master the Key Concepts of CSS for Modern Web Development Rating: 0 out of 5 stars0 ratings
Programming For You
Learn to Code. Get a Job. The Ultimate Guide to Learning and Getting Hired as a Developer. Rating: 5 out of 5 stars5/5Hacking: Ultimate Beginner's Guide for Computer Hacking in 2018 and Beyond: Hacking in 2018, #1 Rating: 4 out of 5 stars4/5Grokking Algorithms: An illustrated guide for programmers and other curious people Rating: 4 out of 5 stars4/5Coding All-in-One For Dummies Rating: 4 out of 5 stars4/5SQL QuickStart Guide: The Simplified Beginner's Guide to Managing, Analyzing, and Manipulating Data With SQL Rating: 4 out of 5 stars4/5Python Programming : How to Code Python Fast In Just 24 Hours With 7 Simple Steps Rating: 4 out of 5 stars4/5Excel : The Ultimate Comprehensive Step-By-Step Guide to the Basics of Excel Programming: 1 Rating: 5 out of 5 stars5/5Learn PowerShell in a Month of Lunches, Fourth Edition: Covers Windows, Linux, and macOS Rating: 0 out of 5 stars0 ratingsHTML & CSS: Learn the Fundaments in 7 Days Rating: 4 out of 5 stars4/5SQL: For Beginners: Your Guide To Easily Learn SQL Programming in 7 Days Rating: 5 out of 5 stars5/5Java for Beginners: A Crash Course to Learn Java Programming in 1 Week Rating: 5 out of 5 stars5/5Python for Beginners: Learn the Fundamentals of Computer Programming Rating: 0 out of 5 stars0 ratingsLinux: Learn in 24 Hours Rating: 5 out of 5 stars5/5PYTHON: Practical Python Programming For Beginners & Experts With Hands-on Project Rating: 5 out of 5 stars5/5The Unofficial Guide to Open Broadcaster Software: OBS: The World's Most Popular Free Live-Streaming Application Rating: 0 out of 5 stars0 ratingsLearn JavaScript in 24 Hours Rating: 3 out of 5 stars3/5Python: For Beginners A Crash Course Guide To Learn Python in 1 Week Rating: 4 out of 5 stars4/5SQL All-in-One For Dummies Rating: 3 out of 5 stars3/5HTML in 30 Pages Rating: 5 out of 5 stars5/5Coding All-in-One For Dummies Rating: 0 out of 5 stars0 ratingsPython: Learn Python in 24 Hours Rating: 4 out of 5 stars4/5Python Machine Learning By Example Rating: 4 out of 5 stars4/5Programming Arduino: Getting Started with Sketches Rating: 4 out of 5 stars4/5
Reviews for jQuery 1.4 Animation Techniques Beginner's Guide
0 ratings0 reviews
Book preview
jQuery 1.4 Animation Techniques Beginner's Guide - Dan Wellman
Table of Contents
jQuery 1.4 Animation Techniques Beginner's Guide
Credits
Foreword
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers and more
Why Subscribe?
Free Access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Time for action – heading
What just happened?
Pop quiz – heading
Have a go hero – heading
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Introduction
Animation on the Web
The power of animated UIs
When to use animations
When not to use animations
Animation checklist
Animating with jQuery
The template file
Creating a project folder
A basic animation example
Time for action – creating an animated loader
What just happened?
Pop quiz – basic animation with jQuery
Have a go hero – extending the loading animation
Summary
2. Fading Animations
Fading animations
Configuring the animations with arguments
jQuery's Unified Animation API
Enhancing simple CSS hover states with fadeIn
Time for action – adding the underlying markup and styling
What just happened?
Time for action – scripting the animation
What just happened?
Pop quiz – using fadeIn
Have a go hero – doing more with fadeIn
Fading elements out
Time for action – creating the dialog
What just happened?
Pop quiz – using fadeOut
Have a go hero – doing more with fadeout
Fading PNGs in IE
Using fadeToggle() for convenient state-checking logic
Time for action – showing and hiding with fadeToggle()
What just happened?
Pop quiz – using fadeToggle()
Have a go hero – extending fadeToggle()
Greater opacity control with fadeTo()
Animating to partial opacity
Time for action – creating the example page
What just happened?
Time for action – adding the behavior
What just happened?
Pop quiz – using fadeTo
Have a go hero – doing more with fadeTo
Fading table-rows in Internet Explorer
Time for action – fading table-rows in IE
What just happened?
Showing and hiding
Flyout submenus with jQuery's show/hide logic
Time for action – animations with show/hide
What just happened?
Pop quiz – using show and hide
Animated toggling
Time for action – replacing show and hide with toggle
Have a go hero – doing more with toggle
Summary
3. Managing Animations
Working with the queue
Viewing the queue
Time for action - viewing the queue
What just happened?
Pop quiz – viewing the queue
Adding a function to the queue
Time for action – adding a single function to the queue
What just happened?
Pop quiz – adding new items to the array
Using a callback function to keep the queue moving
Time for action – keeping the queue running
What just happened?
Pop quiz – keeping the queue running
Replacing the queue
Time for action – replacing the queue
What just happened?
Pop quiz – replacing the queue
Ensuring custom queues iterate correctly
Time for action – dequeueing functions
What just happened?
Stopping an animation
Time for action – preventing animation build-up using the stop method
What just happened?
Pop quiz – stopping an animation
Delaying queue execution
Clearing the queue
Useful properties of the jQuery object
Globally disabling animations
Changing the default frame rate
Summary
4. Sliding Animations
Sliding elements into view
Time for action – creating a slide-down login form
What just happened?
Pop quiz – sliding elements down
Have a go hero – sliding elements down
Sliding elements out of view
Time for action – sliding elements up
What just happened?
Pop quiz – sliding elements up
Have a go hero – fixing the Cancel link
Toggling the slide
Time for action – using slideToggle
What just happened?
Have a go hero – doing more with slideToggle
Pop quiz – using slideToggle
Easing
Time for action – adding easing
What just happened?
Using an object literal to add easing
Time for action – using the alternative argument format
What just happened?
Have a go hero – using easing
Pop quiz – using easing
The flicker effect
Time for action – avoiding the flicker effect
What just happened?
Time for action – fixing the flicker
What just happened?
Pop quiz – fixing the flicker
Have a go hero – adding a delay before showing a submenu
Summary
5. Custom Animations
The animate method
Per-property easing
An alternative syntax for animate()
Animating an element's position
Time for action – creating an animated content viewer
What just happened?
Time for action – initializing variables and prepping the widget
What just happened?
Time for action – defining a post-animation callback
What just happened?
Time for action – adding event handlers for the UI elements
What just happened?
Skinning the widget
Time for action – adding a new skin
What just happened?
Pop quiz – creating an animated content-viewer
Have a go hero – making the image viewer more scalable
Animating an element's size
Time for action – creating the underlying page and basic styling
What just happened?
Time for action – defining the full and small sizes of the images
What just happened?
Time for action – creating the overlay images
What just happened?
Time for action – creating the overlay wrappers
What just happened?
Time for action – maintaining the overlay positions
What just happened?
Pop quiz – creating expanding images
Have a go hero – doing away with the hardcoded dims object
Creating a jQuery animation plugin
Time for action – creating a test page and adding some styling
What just happened?
Creating the plugin
Time for action – adding a license and defining configurable options
What just happened?
Time for action – adding our plugin method to the jQuery namespace
What just happened?
Time for action – creating the UI
What just happened?
Time for action – creating the transition overlay
What just happened?
Time for action – defining the transitions
What just happened?
Using the plugin
Pop quiz – creating a plugin
Have a go hero – extending the plugin
Summary
6. Extended Animations with jQuery UI
Obtaining and setting up jQuery UI
A new template file
The new effects added by jQuery UI
Using the effect API
The bounce effect
Configuration options
Time for action – using the bounce effect
What just happened?
The highlight effect
Configuration options
Time for action – highlighting elements
What just happened?
The pulsate effect
Configuration options
Time for action – making an element pulsate
What just happened?
The shake effect
Configuration options
Time for action – shaking an element
What just happened?
The size effect
Configuration options
Time for action – resizing elements
What just happened?
The transfer effect
Configuration options
Time for action – transferring the outline of one element to another
What just happened?
Pop quiz – using the effect API
Using effects with show and hide logic
The blind effect
Configuration options
Time for action – using the blind effect
What just happened?
The clip effect
Configuration options
Time for action – clipping an element in and out
What just happened?
The drop effect
Configuration options
Time for action – using the effect
What just happened?
The explode effect
Configuration options
Time for action – exploding an element
What just happened?
The fold effect
Configuration options
Time for action – folding an element away
What just happened?
The puff effect
Configuration options
Time for action – making an element disappear in a puff
What just happened?
The slide effect
Configuration options
Time for action – sliding elements in and out of view
What just happened?
The scale effect
Configuration options
Time for action – scaling an element
What just happened?
Pop quiz – using show/hide logic
Have a go hero – experimenting with the effect API
Easing functions
Time for action – adding easing to effects
What just happened?
Color animations
Time for action – animating between colors
What just happened?
Class transitions
Time for action – transitioning between classes
What just happened?
Pop quiz – easing, color, and class animations
Summary
7. Full Page Animations
Animated page scroll
Time for action – creating the page that will scroll and its styling
What just happened?
Time for action – animating the scroll
What just happened?
Pop quiz – animating page scroll
Have a go hero – extending animated page scroll
The illusion of depth with parallax
A little help from the new cssHooks functionality
Time for action – creating the stage and adding the styling
What just happened?
Time for action – animating the background position
What just happened?
Pop quiz – implementing the parallax effect
Have a go hero – extending parallax
Animated single-page navigation
Time fr action – creating individual pages and adding the styles
What just happened?
Time for action – adding the scroll navigation
What just happened?
Pop quiz – creating a single-page website
Have a go hero – extending single-page navigation
Stop-motion animation
Imagery
Technique
Time for action – adding the markup and styling
What just happened?
Time for action – creating the frames and running the animation
What just happened?
Pop quiz – implementing stop-motion animation with jQuery
Have a go hero – extending stop-motion animation
Summary
8. Other Popular Animations
Proximity animations
Time for action – creating and styling the page
What just happened?
Time for action – prepping the page for sliding functionality
What just happened?
Time for action – animating the scroller
What just happened?
Time for action – adding the mouse events
What just happened?
Time for action – adding keyboard events
What just happened?
Have a go hero – extending proximity animations
Pop quiz – implementing proximity animations
Animated page headers
Time for action – creating an animated header
What just happened?
Have a go hero – extending the animated header
Marquee text
Time for action – creating and styling the underlying page
What just happened?
Time for action – retrieving and processing the post list
What just happened?
Time for action – animating the post links
What just happened?
Have a go hero – extending the marquee scroller
Pop Quiz – creating a marquee scroller
Summary
9. CSS3 Animations
CSS3 2D transforms
Understanding the matrix
Translate
Scale
Skew
Rotation
Working with transforms
jQuery and transforms
Internet Explorer transforms
CSS3 3D transforms
Animated rotation with jQuery and CSS3
Time for action – animating an element's rotation
What just happened?
Problems with IE
Pop quiz – implementing CSS3 rotation
Have a go hero – extending CSS3 rotation
Animated skewing
Time for action – creating the underlying markup and basic styling
What just happened?
Time for action – initializing the widget
What just happened?
Time for action – animating an element's skew
What just happened?
Time for action – skewing an element from left to right
What just happened?
Time for action – wiring up the controls
What just happened?
Pop quiz – using the matrix
Have a go hero – extending matrix animation
Summary
10. Canvas Animations
The canvas API
The canvas element
Context methods
Native shapes
Paths
Images and patterns
Text
Transformation methods
Pixel manipulation
Drawing to the canvas
Time for action – drawing to the canvas
What just happened?
Pop quiz – drawing to the canvas
Have a go hero – creating the flag of your nation
Canvas, IE, and the alternatives
API methods that simply do not work
Time for action – making our code compatible with IE
What just happened?
Pop Quiz – supporting IE
Have a go hero – extending IE support
Animating the canvas
Time for action – creating an animation on the canvas
What just happened?
Time for action – animating the white crosses
What just happened?
Time for action – animating the red crosses
What just happened?
Pop quiz – animating the canvas
Have a go hero – creating canvas animations
Creating a canvas game
Time for action – creating the initial page
What just happened?
Time for action – the initial script
What just happened?
Time for action – adding the aliens to the page
What just happened?
Time for action – moving the aliens
What just happened?
Time for action – adding handlers to control the ship
What just happened?
Pop quiz – creating canvas-based games
Have a go hero – extending the space invaders clone
Summary
A. Pop Quiz Answers
Chapter 1
Basic animation with jQuery
Chapter 2
Using fadeIn
Using fadeOut
Using fadeToggle()
Using fadeTo
Using show and hide
Chapter 3
Viewing the queue
Adding new items to the array
Keeping the queue running
Replacing the queue
Stopping an animation
Chapter 4
Sliding elements down
Sliding elements up
Using slideToggle
Using easing
Fixing the flicker
Chapter 5
Creating an animated content-viewer
Creating expanding images
Creating a plugin
Chapter 6
Using the effect API
Using show/hide logic
Easing, color, and class animations
Chapter 7
Animating page scroll
Implementing the parallax effect
Creating a single-page website
Implementing stop-motion animation with jQuery
Chapter 8
Implementing proximity animations
Creating a marquee scroller
Chapter 9
Implementing CSS3 rotation
Using the matrix
Chapter 10
Drawing to the canvas
Supporting IE
Animating the canvas
Creating canvas-based games
Index
jQuery 1.4 Animation TechniquesBeginner's Guide
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 ( <Filosarti@tiscali.it> )
Credits
Author
Dan Wellman
Reviewers
Shaiful Islam
Ben Nadel
Cyril Pierron
Acquisition Editor
Sarah Cullington
Development Editor
Roger D'souza
Technical Editor
Conrad Sardinha
Indexer
Hemangini Bari
Editorial Team Leader
Akshara Aware
Project Team Leader
Priya Mukherji
Project Coordinator
Sneha Harkut
Proofreader
Aaron Nash
Production Coordinator
Melwyn D'sa
Cover Work
Melwyn D'sa
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
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 atwww.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access.
For Pat Spacagna, the greatest mother-in-law I could have wished for. You are fondly remembered, but sorely missed. May you rest in peace always.
Preface
jQuery is a cross-browser JavaScript library designed to simplify the client-side scripting of HTML, and is the most popular JavaScript library in use today. Using the features offered by jQuery, developers are able to create dynamic web pages. This book will act as a resource for you to create animation and advanced special effects in your web applications, by following the easy-to-understand steps mentioned in it.
jQuery 1.4 Animation Techniques: Beginner's Guide will allow you to master animation in jQuery to produce slick and attractive interfaces that respond to your visitors' interactions. You will learn everything you need to know about creating engaging and effective web page animations using jQuery. The book uses many examples and explains how to create animations using an easy, step-by-step, beginner's guide approach.
This book provides various examples that gradually build up the reader's knowledge and practical experience in using the jQuery API to create stunning animations. The book starts off by explaining how animations make your user interface interactive and attractive. It explains the various methods used to make the element being animated appear or disappear. It provides a set of steps to create simple animations and show fading animations.
You can later learn how to make complex animations by chaining different effects together as well as how to halt a currently running application. You will find out how to slide your animation elements and learn to create custom animations that can be complex and specialized.
You will find out how to obtain and set up the jQuery UI—the official user interface library for jQuery. This book will tell you how to animate a page's background image, and will teach you how to make images scroll in a certain direction and at a certain speed depending on the movement of the mouse pointer.
What this book covers
Chapter 1, Introduction covers the basics including downloading jQuery and setting up a development area, a brief history of animation on the Web, when and where not to use animation, how animation can enhance an interface, and the animation methods exposed by jQuery. A basic example of animation is also covered.
Chapter 2, Fading Animations looks at the fading family of animation methods including fading elements in and out, fade toggling, triggering animations with show(), hide(), and toggle(), and fading an element to a specific opacity.
Chapter 3, Managing Animations covers the animation queue and the methods jQuery provides for managing it. We see how to clear the queue, how to add functions to it, and how to clear it. We see how to add a delay between queued items and how to prevent animations building up in the queue when they are not required.
Chapter 4, Sliding Animations looks at jQuery's sliding animation and covers how to slide elements in an out of view and how to toggle the slide based on their current state. We also look at how CSS positioning can affect animations and how to avoid a common pitfall when using these methods in a drop-down menu.
Chapter 5, Custom Animations focuses on the animate() method, which jQuery provides for us as a means of creating custom animations not already predefined. This extremely powerful method allows us to animate almost any CSS-style property to easily create complex and attractive animations.
Chapter 6, Extended Animations with jQuery UI looks at the additional effects added by jQuery UI, the official UI library built on top of jQuery. We look at each of the 14 new effects as well as covering the easing functions built into the library.
Chapter 7, Full Page Animations looks at animations that form the main focus of the page. Techniques we cover include animating page scroll, creating a parallax effect, and creating basic stop-motion animations.
Chapter 8, Other Popular Animations looks at some common types of animations found on the web including proximity animations triggered by the mouse pointer, animated headers, and a modern-day equivalent to the marquee element.
Chapter 9, CSS3 Animations covers how we can use CSS3 to create attractive animations driven by the latest CSS transforms and how jQuery can be used to make the process easier, including the latest cssHooks functionality.
Chapter 10, Canvas Animations looks at the HTML5 canvas element and shows how it can be used to create stunning animations without the use of Flash or other proprietary technologies. The book closes with an in-depth example teaching how to create an interactive game using nothing but HTML and JavaScript.
What you need for this book
To get the most out of this book you should have some knowledge of frontend development, preferably including JavaScript. Experience with jQuery is also preferable, but is not essential as all techniques used in the book are discussed in full.
You should have a computer capable of running the latest browsers and preferably an Internet connection. A code editing development software package will be of help, but again is not essential provided you have a text editor of some description.
Who this book is for
This book is written for web designers and frontend developers who already have good knowledge of HTML and CSS, and some experience with jQuery. If you want to learn how to animate the user interface of your web applications with jQuery, then this book is for you.
Conventions
In this book, you will find several headings appearing frequently.
To give clear instructions of how to complete a procedure or task, we use:
Time for action – heading
Action 1
Action 2
Action 3
Instructions often need some extra explanation so that they make sense, so they are followed with:
What just happened?
This heading explains the working of tasks or instructions that you have just completed.
You will also find some other learning aids in the book, including:
Pop quiz – heading
These are short multiple choice questions intended to help you test your own understanding.
Have a go hero – heading
These set practical challenges and give you ideas for experimenting with what you have learned.
You will also find a number of styles of text that distinguish between different kinds of information. Here are some examples of these