jQuery 1.4 Animation Techniques - Index of
jQuery 1.4 Animation Techniques - Index of jQuery 1.4 Animation Techniques - Index of
Time for action – exploding an element In this example we will make an image explode. 1. Just add the following simple image to the of the template file: [ 163 ] Chapter 6 2. Then add the following equally simple code to the empty function at the bottom of the template file: $("img").click(function() { $(this).effect("explode"); }); 3. Save this page as explode.html. 4. This example is so simple we don't even need a stylesheet. Once we click on the grenade, it is exploded into the default number of pieces: The exploded element fades away as the individual pieces of the element move apart. What just happened? In the example, all we need to do is attach a click handler directly to the image which applies the explode effect using the effect() method. No configuration in this instance is required because the default mode of the effect is hide. Note that we can also run this effect in reverse by setting the mode option to show, or using the show() logic instead. In this scenario, we will see the target element constructed from a series of pieces that fade in and fly together—an explosion in reverse.
Extended Animations with jQuery UI The fold effect The fold effect simulates something being folded in half along one axis and then folded in half along the other axis. Of course, the element isn't actually folded in the 3D sense, first one side of the element moves up a specified amount, then another side is moved in and the element disappears. By default the effect uses the hide mode so it will automatically be hidden at the end of the animation. The element being folded is not scaled; it is clipped instead so images and text will not squash up as the effect runs. Configuration options The fold effect exposes three configurable options which are shown in the following table: Option Default Usage horizFirst false Sets whether the element is clipped along the horizontal axis first or not. mode "hide" Sets whether the element is shown or hidden when used with the effect() method. Other values may include show, effect, or toggle. Size 15 This sets the distance of the first fold in pixels and can take either an integer, or a string specifying a value, such as a percentage. Time for action – folding an element away In this example, we'll apply the effect to a simple image of a piece of paper. 1. All we need is an image; add the following code to the of the template file: 2. Next add the following simple script to the bottom of the page, in the empty function as with previous examples: $("img").click(function() { $(this).effect("fold", { size: "50%" }, 1000); }); 3. Save this file as fold.html. [ 164 ]
- 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 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: 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
- Page 219 and 220: Full Page Animations The second sec
- Page 221 and 222: Full Page Animations Pop quiz - cre
- Page 223 and 224: Full Page Animations Time for actio
- Page 225 and 226: Full Page Animations Next we define
- Page 228 and 229: 8 Other Popular Animations This cha
- Page 230 and 231: [ 209 ] Chapter 8 } .slider #scroll
- Page 232 and 233: }), pointerText = "Use your pointer
Extended <strong>Animation</strong>s with <strong>jQuery</strong> UI<br />
The fold effect<br />
The fold effect simulates something being folded in half along one axis and then folded in<br />
half along the other axis. Of course, the element isn't actually folded in the 3D sense, first<br />
one side <strong>of</strong> the element moves up a specified amount, then another side is moved in and<br />
the element disappears.<br />
By default the effect uses the hide mode so it will automatically be hidden at the end <strong>of</strong> the<br />
animation. The element being folded is not scaled; it is clipped instead so images and text<br />
will not squash up as the effect runs.<br />
Configuration options<br />
The fold effect exposes three configurable options which are shown in the following table:<br />
Option Default Usage<br />
horizFirst false Sets whether the element is clipped along the horizontal axis first<br />
or not.<br />
mode "hide" Sets whether the element is shown or hidden when used with the<br />
effect() method. Other values may include show, effect,<br />
or toggle.<br />
Size 15 This sets the distance <strong>of</strong> the first fold in pixels and can take either<br />
an integer, or a string specifying a value, such as a percentage.<br />
Time for action – folding an element away<br />
In this example, we'll apply the effect to a simple image <strong>of</strong> a piece <strong>of</strong> paper.<br />
1. All we need is an image; add the following code to the <strong>of</strong> the template file:<br />
<br />
2. Next add the following simple script to the bottom <strong>of</strong> the page, in the empty<br />
function as with previous examples:<br />
$("img").click(function() {<br />
$(this).effect("fold", { size: "50%" }, 1000);<br />
});<br />
3. Save this file as fold.html.<br />
[ 164 ]