jQuery 1.4 Animation Techniques - Index of
jQuery 1.4 Animation Techniques - Index of jQuery 1.4 Animation Techniques - Index of
ackground:url(../img/dock.png) no-repeat 0 0; } .icon { position:absolute; top:-15px; left:44px; } .icon img { border:none; } #mail { left:108px; } #safari { left:170px; } #firefox { left:229px; } #itunes { left:289px; } 4. Save this file as size.css in the css folder. 5. When we run the file in a browser, we should see that the individual items in the menu grow and shrink as the mouse pointer moves over them: [ 151 ] Chapter 6 In the previous screenshot we see the menu as the pointer hovers over one of the items in the menu. What just happened? We attach mouseenter and mouseleave event handlers to each item within the dock using jQuery's hover() method, which accepts two functions, the first being executed on the mouseenter event, the second being executed on mouseleave. In the first function we use the stop() method to manage the queue and then animate the element's position by changing its top CSS value. Using stop() here prevents an unsightly jarring of the element's position on screen. We then navigate down the image inside the link and call the stop() method on this element too before applying the size effect. We provide integer values for the width and height keys in a configuration object and as these values are larger than the dimensions of the image, the image will be increased in size.
Extended Animations with jQuery UI Note that when we use the stop() method with the image, it is to prevent a build-up of effects if the mouse pointer is repeatedly moved on and off one of the links. The second function is really the reverse of the first function, which simply resizes the element back to its original position and size. The transfer effect The transfer effect simply transfers the outline of one element to another element. Like the size effect that we looked at a moment ago, the transfer effect will not work if it is not configured. Configuration options The transfer effect has only two configuration options, although only one is mandatory. These options are listed in the following table: Option Default Usage className none The value of this option, if set, is added to the transfer element when the effect runs to none A jQuery selector that specifies the target element that the transfer element is sent to Time for action – transferring the outline of one element to another In this example we'll recreate a popular application installation dialog from OSX, and use the transfer effect to help show visitors where to drag the icon (the icon won't actually be draggable, all we're doing is looking at the transfer effect). 1. Add the following elements to the of the template file to create the install dialog: To install the application, drag its icon over to the apps folder icon. Show me [ 152 ]
- 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 and 168: Extended Animations with jQuery UI
- Page 169 and 170: Extended Animations with jQuery UI
- Page 171: Download from Wow! eBook Extended
- 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
- Page 219 and 220: Full Page Animations The second sec
- Page 221 and 222: Full Page Animations Pop quiz - cre
ackground:url(../img/dock.png) no-repeat 0 0;<br />
}<br />
.icon { position:absolute; top:-15px; left:44px; }<br />
.icon img { border:none; }<br />
#mail { left:108px; }<br />
#safari { left:170px; }<br />
#firefox { left:229px; }<br />
#itunes { left:289px; }<br />
4. Save this file as size.css in the css folder.<br />
5. When we run the file in a browser, we should see that the individual items in the<br />
menu grow and shrink as the mouse pointer moves over them:<br />
[ 151 ]<br />
Chapter 6<br />
In the previous screenshot we see the menu as the pointer hovers over one <strong>of</strong> the items in<br />
the menu.<br />
What just happened?<br />
We attach mouseenter and mouseleave event handlers to each item within the dock using<br />
<strong>jQuery</strong>'s hover() method, which accepts two functions, the first being executed on the<br />
mouseenter event, the second being executed on mouseleave.<br />
In the first function we use the stop() method to manage the queue and then animate the<br />
element's position by changing its top CSS value. Using stop() here prevents an unsightly<br />
jarring <strong>of</strong> the element's position on screen.<br />
We then navigate down the image inside the link and call the stop() method on this<br />
element too before applying the size effect. We provide integer values for the width and<br />
height keys in a configuration object and as these values are larger than the dimensions <strong>of</strong><br />
the image, the image will be increased in size.