jQuery 1.4 Animation Techniques - Index of
jQuery 1.4 Animation Techniques - Index of jQuery 1.4 Animation Techniques - Index of
Download from Wow! eBook The following screenshot shows an image in IE8 fading out correctly: We can see in the previous screenshot that there are no black borders around the image while it is fading out in IE8. In this example, I put the PNG into a container, set the background-color of the container to white, and faded out the container. [ 33 ] Chapter 2 Using fadeToggle() for convenient state-checking logic The fadeToggle() method exposed by jQuery will either fade an element in, or fade it out depending on the current state of the element. Elements that are visible will be faded out, while elements that are hidden will be faded in. When elements are faded out with fadeToggle(), they will automatically be set to display:none at the end of the animation so that the element doesn't affect the layout of the page.
Fading Animations Time for action – showing and hiding with fadeToggle() As before, we first create the HTML markup and CSS styling required by the example. 1. Open up a new copy of the template file and add the following code to the of the page: Enter your name: Your name. You know, the thing that people call you by 2. Save this page as fadeToggle.html. Next we need to add a few styles. In a new page in your text editor, add the following code: form { width:280px; margin:100px auto; position:relative; } input { margin-left:5px; } #help { display:block; width:16px; height:16px; margin-top:3px; float:right; cursor:pointer; background:url(../img/help.png) no-repeat; } #helpText { display:none; width:100px; height:75px; padding:12px 18px; position:absolute; left:115px; top:-90px; font:normal 12px "Nimbus Sans L", "Helvetica Neue", "Franklin Gothic Medium", Sans-serif; background:url(../img/bubble.png) no-repeat; } 3. Save this file as fadeToggle.css in the css folder. Finally, let's add the script that will make the example work. Within the anonymous function in the second element, add the following code: $("#help").click(function() { $("#helpText").fadeToggle(); }); What just happened? On the page we have a simple containing a label, an , and a couple of elements. The first is used as an icon, while the second contains help text to prompt the user for the value the expects. [ 34 ]
- Page 4 and 5: Author Dan Wellman Reviewers Shaifu
- Page 6 and 7: About the Author Dan Wellman is an
- Page 8 and 9: Cyril Pierron is an engineer, a web
- Page 12: For Pat Spacagna, the greatest moth
- Page 15 and 16: Download from Wow! eBook Table of
- Page 17 and 18: Table of Contents Time for action -
- Page 19 and 20: Table of Contents jQuery and transf
- Page 21 and 22: Drawing to the canvas 309 Supportin
- Page 23 and 24: Preface What this book covers Chapt
- Page 25 and 26: Preface Have a go hero - heading Th
- Page 27 and 28: Preface Piracy Piracy of copyright
- Page 29 and 30: Introduction In addition to animate
- Page 31 and 32: Introduction When not to use animat
- Page 33 and 34: Introduction of the template file"
- Page 35 and 36: Introduction In the previous screen
- Page 37 and 38: Introduction Once our variables hav
- Page 40 and 41: 2 Fading Animations In this chapter
- Page 42 and 43: [ 21 ] Chapter 2 We can control the
- Page 44 and 45: The previous screenshot shows how t
- Page 46 and 47: [ 25 ] Chapter 2 Most of the styles
- Page 48 and 49: 2. What else can be passed into the
- Page 50 and 51: Time for action - creating the dial
- Page 52 and 53: [ 31 ] Chapter 2 For example, the a
- Page 56 and 57: [ 35 ] Chapter 2 The CSS is used mo
- Page 58 and 59: The fadeTo() method is used in the
- Page 60 and 61: [ 39 ] Chapter 2 #messageList table
- Page 62 and 63: [ 41 ] Chapter 2 What just happened
- Page 64 and 65: 2. What format can these arguments
- Page 66 and 67: } var el = $(this); if (el.css("fil
- Page 68 and 69: [ 47 ] Chapter 2 Usually these meth
- Page 70 and 71: Time for action - animations with s
- Page 72 and 73: Download from Wow! eBook [ 51 ] Ch
- Page 74 and 75: 2. Save the changes as toggle.html.
- Page 76 and 77: 3 Managing Animations Like most of
- Page 78 and 79: [ 57 ] Chapter 3 A custom queue tha
- Page 80 and 81: If we wish to see how many function
- Page 82 and 83: 2. What does the queue() method ret
- Page 84 and 85: [ 63 ] Chapter 3 The argument we su
- Page 86 and 87: [ 65 ] Chapter 3 We pass a callback
- Page 88 and 89: [ 67 ] Chapter 3 The first argument
- Page 90 and 91: Delaying queue execution [ 69 ] Cha
- Page 92 and 93: [ 71 ] Chapter 3 Also note that the
- Page 94 and 95: 4 Sliding Animations Another type o
- Page 96 and 97: Time for action - creating a slide-
- Page 98 and 99: [ 77 ] Chapter 4 header form input
- Page 100 and 101: Pop quiz - sliding elements down 1.
- Page 102 and 103: Download from Wow! eBook }); }); $
Download from Wow! eBook <br />
The following screenshot shows an image in IE8 fading out correctly:<br />
We can see in the previous screenshot that there are no black borders around the<br />
image while it is fading out in IE8. In this example, I put the PNG into a container, set the<br />
background-color <strong>of</strong> the container to white, and faded out the container.<br />
[ 33 ]<br />
Chapter 2<br />
Using fadeToggle() for convenient state-checking logic<br />
The fadeToggle() method exposed by <strong>jQuery</strong> will either fade an element in, or fade it out<br />
depending on the current state <strong>of</strong> the element. Elements that are visible will be faded out,<br />
while elements that are hidden will be faded in.<br />
When elements are faded out with fadeToggle(), they will automatically be set to<br />
display:none at the end <strong>of</strong> the animation so that the element doesn't affect the layout<br />
<strong>of</strong> the page.