jQuery 1.4 Animation Techniques - Index of
jQuery 1.4 Animation Techniques - Index of jQuery 1.4 Animation Techniques - Index of
[ 85 ] Chapter 4 } h2 { margin:0; padding:7px 0 7px 14px; -moz-border-radius:7px; -webkit-border-radius:7px; border-radius:7px; color:#fff; background-image:-moz-linear-gradient(0% 22px 90deg, #222, #999); background-image:-webkit-gradient(linear, 0% 0%, 0% 50%, from(#999), to(#222)); } #basketToggle { position:absolute; right:14px; top:10px; color:#ccc; } #basketToggle:hover { color:#fff; } #basketToggle:active { color:#ddd; } #basketToggle:focus { outline:none; color:#ddd; } table { width:860px; margin:auto; border-collapse:collapse; border-spacing:0; } td, th { padding:20px 10px; border:1px solid #000; } th { border-top:none; } #contents { display:none; } #contents table { background-color:#fff; } .summary td, th { background-color:#ccc; background-image:-moz-linear-gradient(0% 40% 90deg, #ccc, #fff); background-image:-webkit-gradient(linear, 0% 0%, 0% 40%, from(#fff), to(#ccc)); } .qty, .desc { width:50px; text-align:left; } .qty, #total .subtotal { border-left:none; } .subtotal, .total { width:112px; } .subtotal { text-align:right; border-left:0; } .total { text-align:left; border-right:none; } .vat .subtotal, .vat .total { border-bottom:none; } #total .subtotal, #total .total { border-bottom:none; } #total td { color:#fff; border:1px solid #fff; } #total .total { border-right:none; font-weight:bold; } .summary .subtotal, #total .subtotal, .desc { width:auto; } #total .subtotal, #total .total { -moz-border-radius:0 0 7px 7px; -webkit-border-radius-bottom-left:7px; -webkit-border-radius-bottom-right:7px; border-radius:0 0 7px 7px; background-image:-moz-linear-gradient(0% 70% 90deg, #222, #999); background-image:-webkit-gradient(linear, 0% 0%, 0% 70%, from(#999), to(#222)); }
Sliding Animations 4. Save this in the css folder as slideToggle.css and link to the file from the of the page we just created. 5. For the final part of the example we can add the script that will toggle the visibility of the contents table. Add the following code to the bottom of the HTML page: var toggler = $("#basketToggle"), basketArea = $("#contents"), newText = ["", "basket", "contents"]; toggler.click(function(e) { } }); e.preventDefault(); if (!basketArea.is(":animated")) { basketArea.slideToggle("slow", function(){ toggler.text(function(i, text) { if (basketArea.is(":visible")) { newText[0] = "Hide"; } else { newText[0] = "Show"; } toggler.text(newText.join(" ")); }); }); 6. Run the page in your browser now. You should find that you can open or close the contents section of the basket area by clicking the link in the top-right of the container. The basket area should expand like this: [ 86 ]
- 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 }); }); $
- Page 104 and 105: Toggling the slide [ 83 ] Chapter 4
- Page 108 and 109: [ 87 ] Chapter 4 The previous scree
- Page 110 and 111: Pop quiz - using slideToggle 1. Wha
- Page 112 and 113: [ 91 ] Chapter 4 Easing is a great
- Page 114 and 115: [ 93 ] Chapter 4 Home Articles J
- Page 116 and 117: [ 95 ] Chapter 4 3. Save this file
- Page 118 and 119: In the previous screenshot, we see
- Page 120 and 121: Pop quiz - fixing the flicker 1. Wh
- Page 122 and 123: 5 Custom Animations The predefined
- Page 124 and 125: An alternative syntax for animate()
- Page 126 and 127: [ 105 ] Chapter 5 width:295px; marg
- Page 128 and 129: [ 107 ] Chapter 5 What just happene
- Page 130 and 131: [ 109 ] Chapter 5 Although not esse
- Page 132 and 133: [ 111 ] Chapter 5 The previous scre
- Page 134 and 135: [ 113 ] Chapter 5 The styles we use
- Page 136 and 137: [ 115 ] Chapter 5 What just happene
- Page 138 and 139: }, html: copy, width: expander.widt
- Page 140 and 141: [ 119 ] Chapter 5 If the image alre
- Page 142 and 143: [ 121 ] Chapter 5 d. Two objects wh
- Page 144 and 145: [ 123 ] Chapter 5 text-align:center
- Page 146 and 147: [ 125 ] Chapter 5 What just happene
- Page 148 and 149: [ 127 ] Chapter 5 Finally, we retur
- Page 150 and 151: [ 129 ] Chapter 5 Once we've define
- Page 152 and 153: } }; $(config.selector).find("a").c
- Page 154 and 155: [ 133 ] Chapter 5 In the previous s
[ 85 ]<br />
Chapter 4<br />
}<br />
h2 {<br />
margin:0; padding:7px 0 7px 14px; -moz-border-radius:7px;<br />
-webkit-border-radius:7px; border-radius:7px; color:#fff;<br />
background-image:-moz-linear-gradient(0% 22px 90deg, #222,<br />
#999);<br />
background-image:-webkit-gradient(linear, 0% 0%, 0% 50%,<br />
from(#999), to(#222));<br />
}<br />
#basketToggle {<br />
position:absolute; right:14px; top:10px; color:#ccc;<br />
}<br />
#basketToggle:hover { color:#fff; }<br />
#basketToggle:active { color:#ddd; }<br />
#basketToggle:focus { outline:none; color:#ddd; }<br />
table {<br />
width:860px; margin:auto; border-collapse:collapse;<br />
border-spacing:0;<br />
}<br />
td, th { padding:20px 10px; border:1px solid #000; }<br />
th { border-top:none; }<br />
#contents { display:none; }<br />
#contents table { background-color:#fff; }<br />
.summary td, th {<br />
background-color:#ccc;<br />
background-image:-moz-linear-gradient(0% 40% 90deg, #ccc, #fff);<br />
background-image:-webkit-gradient(linear, 0% 0%, 0% 40%,<br />
from(#fff), to(#ccc));<br />
}<br />
.qty, .desc { width:50px; text-align:left; }<br />
.qty, #total .subtotal { border-left:none; }<br />
.subtotal, .total { width:112px; }<br />
.subtotal { text-align:right; border-left:0; }<br />
.total { text-align:left; border-right:none; }<br />
.vat .subtotal, .vat .total { border-bottom:none; }<br />
#total .subtotal, #total .total { border-bottom:none; }<br />
#total td { color:#fff; border:1px solid #fff; }<br />
#total .total { border-right:none; font-weight:bold; }<br />
.summary .subtotal, #total .subtotal, .desc { width:auto; }<br />
#total .subtotal, #total .total {<br />
-moz-border-radius:0 0 7px 7px;<br />
-webkit-border-radius-bottom-left:7px;<br />
-webkit-border-radius-bottom-right:7px; border-radius:0 0 7px<br />
7px;<br />
background-image:-moz-linear-gradient(0% 70% 90deg, #222, #999);<br />
background-image:-webkit-gradient(linear, 0% 0%, 0% 70%,<br />
from(#999), to(#222));<br />
}