jQuery 1.4 Animation Techniques - Index of
jQuery 1.4 Animation Techniques - Index of jQuery 1.4 Animation Techniques - Index of
[ 143 ] Chapter 6 The highlight effect The highlight effect is a simple but effective way to draw the visitor's attention to new items that have been added to the page, and is used for this purpose in many of today's leading web-based interfaces. Configuration options There are only two configuration options for the highlight effect; these are listed as follows: Options Default Usage color "#ffff99" Sets the background-color of the element being highlighted. mode "show" Sets whether the effect will be hidden or shown when used with the effect() method. Other possible values include hide, toggle, or effect. Time for action – highlighting elements In this example we'll create a simple todo list, with a series of default items that can be checked off. We can also allow new items to be added to the list and will apply the highlight effect to new items as they are added. 1. Add the following HTML to the of the template file: Todo List Item 1 Item 2 Item 3 Add 2. Add the behavior for our todo list using the following code: $("#add").click(function() { var newItem = $("#new"), text = newItem.val(); if (text) { var li = $(""), label = $("").html( "" + text).appendTo(li);
Extended Animations with jQuery UI } }); li.appendTo("#todo ul").effect("highlight", 2000); newItem.val(""); 3. Save this page as highlight.html. We also need some CSS for this example. In a new file in your text editor add the following code: #todo { width:208px; font:normal 13px "Nimbus Sans L", "Helvetica Neue", "Franklin Gothic Medium", Sans-serif; } #todo ul { padding:0; margin-bottom:30px; } #todo li { list-style-type:none; } #todo label { display:block; border-bottom:1px dotted #000; } li input { position:relative; top:2px; } input { margin-right:10px; } 4. Save this page as highlight.css. 5. When we run the page in a browser, we can add a new item and it will be highlighted briefly as the new item is added to the list: In the previous screenshot we see the fade effect before it fades away from the newly added item. [ 144 ]
- 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
- Page 156: Have a go hero - extending the plug
- Page 159 and 160: Extended Animations with jQuery UI
- Page 161 and 162: Extended Animations with jQuery UI
- Page 163: Extended Animations with jQuery UI
- Page 167 and 168: Extended Animations with jQuery UI
- Page 169 and 170: Extended Animations with jQuery UI
- Page 171 and 172: Download from Wow! eBook Extended
- Page 173 and 174: Extended Animations with jQuery UI
- Page 175 and 176: Extended Animations with jQuery UI
- Page 177 and 178: Extended Animations with jQuery UI
- Page 179 and 180: Extended Animations with jQuery UI
- Page 181 and 182: Extended Animations with jQuery UI
- Page 183 and 184: Extended Animations with jQuery UI
- Page 185 and 186: Extended Animations with jQuery UI
- Page 187 and 188: Extended Animations with jQuery UI
- Page 189 and 190: Extended Animations with jQuery UI
- Page 191 and 192: Extended Animations with jQuery UI
- Page 193 and 194: Extended Animations with jQuery UI
- Page 195 and 196: Extended Animations with jQuery UI
- Page 197 and 198: Extended Animations with jQuery UI
- Page 199 and 200: Extended Animations with jQuery UI
- Page 201 and 202: Full Page Animations Can we animate
- Page 203 and 204: Full Page Animations display:block;
- Page 205 and 206: Download from Wow! eBook Full Page
- Page 207 and 208: Full Page Animations Have a go hero
- Page 209 and 210: Full Page Animations 4. Save this f
- Page 211 and 212: Full Page Animations 2. The bgpos c
- Page 213 and 214: Full Page Animations nav ul { margi
[ 143 ]<br />
Chapter 6<br />
The highlight effect<br />
The highlight effect is a simple but effective way to draw the visitor's attention to new items<br />
that have been added to the page, and is used for this purpose in many <strong>of</strong> today's leading<br />
web-based interfaces.<br />
Configuration options<br />
There are only two configuration options for the highlight effect; these are listed as follows:<br />
Options Default Usage<br />
color "#ffff99" Sets the background-color <strong>of</strong> the element being highlighted.<br />
mode "show" Sets whether the effect will be hidden or shown when used with the<br />
effect() method. Other possible values include hide, toggle,<br />
or effect.<br />
Time for action – highlighting elements<br />
In this example we'll create a simple todo list, with a series <strong>of</strong> default items that can be<br />
checked <strong>of</strong>f. We can also allow new items to be added to the list and will apply the highlight<br />
effect to new items as they are added.<br />
1. Add the following HTML to the <strong>of</strong> the template file:<br />
<br />
Todo List<br />
<br />
Item 1<br />
Item 2<br />
Item 3<br />
<br />
Add<br />
<br />
2. Add the behavior for our todo list using the following code:<br />
$("#add").click(function() {<br />
var newItem = $("#new"),<br />
text = newItem.val();<br />
if (text) {<br />
var li = $(""),<br />
label = $("").html(<br />
"" + text).appendTo(li);