Download presentation
Presentation is loading. Please wait.
Published byVictoria Hill Modified over 9 years ago
1
5. Energizing pages with animations and effects BEAR BIBEAULT YEHUDA KATZ
2
This chapter covers Showing and hiding elements without animation Showing and hiding elements using core animation effects Writing custom animations Controlling animation and function queuing
3
5.1 Showing and hiding elements As simple as these methods may seem, we should keep a few things in mind. First, jQuery hides elements by changing their style.display properties to none. If an element in the wrapped set is already hidden, it will remain hidden but still be returned for chaining. For example, suppose we have the following HTML fragment:
4
5.1 Showing and hiding elements The methods for showing and hiding elements are pretty much what we’d expect: show() to show the elements in a wrapped set, and hide() to hide them. We’re going to delay presenting their formal syntax for reasons that will become clear in a bit; for now, let’s concentrate on using these methods with no parameters.
5
5.2 Animating the display state of elements
9
5.2.1 Fading elements into and out of existence
12
5.2.2 Sliding elements up and down
15
5.2.3 Stopping animations
16
5.3 Creating custom animations
18
5.3.1 A custom scale animation
19
5.3.2 A custom drop animation
20
5.3.3 A custom puff animation
21
5.4 Animations and Queuing We’ve seen how multiple properties of elements can be animated using a single animation method, but we haven’t really examined how animations behave when we call simultaneous animation methods. In this section we’ll examine just how animations behave in concert with each other.
22
5.4.1 Simultaneous animations What would you expect to happen if we were to execute the following code? $('#testSubject').animate({left:'+=256'},'slow'); $('#testSubject').animate({top:'+=256'},'slow');
23
5.4.2 Queuing functions for execution Compare that to the equivalent code that would be necessary without function queuing, using the completion callbacks:
24
5.4.2 Queuing functions for execution
29
Q & A setTimeout
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.