Presentation is loading. Please wait.

Presentation is loading. Please wait.

5. Energizing pages with animations and effects BEAR BIBEAULT YEHUDA KATZ.

Similar presentations


Presentation on theme: "5. Energizing pages with animations and effects BEAR BIBEAULT YEHUDA KATZ."— Presentation transcript:

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

6

7

8

9 5.2.1 Fading elements into and out of existence

10

11

12 5.2.2 Sliding elements up and down

13

14

15 5.2.3 Stopping animations

16 5.3 Creating custom animations

17

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

25

26

27

28

29 Q & A setTimeout


Download ppt "5. Energizing pages with animations and effects BEAR BIBEAULT YEHUDA KATZ."

Similar presentations


Ads by Google