jQuery 1.4 Animation Techniques - Index of
jQuery 1.4 Animation Techniques - Index of jQuery 1.4 Animation Techniques - Index of
[ 147 ] Chapter 6 What just happened? When a Delete link is clicked, our handler function first sets the background-color of the that the link is within. This is not mandatory for the effect, but it does help bring it to life. We then apply the pulsate effect to all elements within the row using the effect() method. We need to apply the effect to the elements instead of the element so that the effect works as intended in IE. When the effect ends, our inline callback function will be executed which removes the . Obviously the can only be removed once, but once it has been removed, subsequent attempts to remove it will just fail silently. The shake effect The shake effect shakes the element that it is applied to back and forth a specified number of times. Configuration options The shake effect exposes three configuration options that allow us to customize its behavior. These are listed in the following table: Option Default Usage direction "left" Sets the direction that the element moves in distance 20 Sets the number of pixels the element travels when it is shaken times 3 Sets the number of times the element shakes Time for action – shaking an element The open source .Net CMS Umbraco uses the shake effect when incorrect login details are entered in the sign-in form for its back-office administration area. In this example we can see how easy it is to implement this behavior using the shake effect. 1. Add the following markup to the template file as the basis of the log in form: Login Username: Password: Login
Extended Animations with jQuery UI 2. Now add the following code to the empty closure at the bottom of the template file: $("#submit").click(function(e) { e.preventDefault(); $("input").each(function(i, val) { if (!$(this).val()) { $(this).css("border", "1px solid red").effect("shake", { distance: 5 }, 100); } }); }); 3. Save this file as shake.html. We also need a basic stylesheet for this example. Add the following CSS to a new file: form { width:145px; padding:20px; margin:auto; border:1px solid #000; font:normal 13px "Nimbus Sans L", "Helvetica Neue", "Franklin Gothic Medium", Sans-serif; } h2 { font-size:14px; margin-top:0; } input { display:block; margin-bottom:10px; border:1px solid #000; } 4. Save this file as shake.css. 5. If we run the page in a browser and click the without completing either of the fields, both fields will have their borders set to red and will shake from side to side: [ 148 ]
- 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 and 164: Extended Animations with jQuery UI
- Page 165 and 166: Extended Animations with jQuery UI
- Page 167: 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
- Page 215 and 216: Full Page Animations screensize = {
- Page 217 and 218: Full Page Animations What just happ
[ 147 ]<br />
Chapter 6<br />
What just happened?<br />
When a Delete link is clicked, our handler function first sets the background-color <strong>of</strong><br />
the that the link is within. This is not mandatory for the effect, but it does help bring<br />
it to life.<br />
We then apply the pulsate effect to all elements within the row using the effect()<br />
method. We need to apply the effect to the elements instead <strong>of</strong> the element so<br />
that the effect works as intended in IE.<br />
When the effect ends, our inline callback function will be executed which removes the .<br />
Obviously the can only be removed once, but once it has been removed, subsequent<br />
attempts to remove it will just fail silently.<br />
The shake effect<br />
The shake effect shakes the element that it is applied to back and forth a specified number<br />
<strong>of</strong> times.<br />
Configuration options<br />
The shake effect exposes three configuration options that allow us to customize its behavior.<br />
These are listed in the following table:<br />
Option Default Usage<br />
direction "left" Sets the direction that the element moves in<br />
distance 20 Sets the number <strong>of</strong> pixels the element travels when<br />
it is shaken<br />
times 3 Sets the number <strong>of</strong> times the element shakes<br />
Time for action – shaking an element<br />
The open source .Net CMS Umbraco uses the shake effect when incorrect login details are<br />
entered in the sign-in form for its back-<strong>of</strong>fice administration area. In this example we can see<br />
how easy it is to implement this behavior using the shake effect.<br />
1. Add the following markup to the template file as the basis <strong>of</strong> the log in form:<br />
<br />
Login<br />
Username:<br />
Password:<br />
Login<br />