jQuery 1.4 Animation Techniques - Index of
jQuery 1.4 Animation Techniques - Index of jQuery 1.4 Animation Techniques - Index of
Pop quiz – using the matrix 1. The CSS3 matrix transform function is useful in which situation? a. When we want to work in radians instead of degrees b. When we need to animate a transform function c. When we want to apply more than one transform function to an element d. When coding for Internet Explorer [ 263 ] Chapter 9 2. In the transform function matrix(a, b, c, d, e, f), which parameters refer to the element's translation? a. a and b b. a and d c. b and c d. e and f Have a go hero – extending matrix animation It would definitely be beneficial to build this example so that it incorporated progressive enhancement. Work on an alternative, accessible layout that works with scripting disabled, and then convert the widget into the format used in this example. You could also work on a more suitable fallback for IE, in which the example uses a simpler image viewer, perhaps one of those looked at earlier in the book. Summary In this chapter we look at the new CSS3 transform style property in detail, covering all of the different transform functions including: matrix rotate scale scaleX scaleY skew skewX skewY
CSS3 Animations translate translateX translateY We learned a lot about the new CSS3 matrix property in this chapter, as well as how to make use of it with jQuery. Specifically, we learned the following: We first saw the different values that these functions take and the effects that they have on elements they are applied to. We also saw that in order to animate these styles, we can use simple native JavaScript intervals or timeouts to continuously adjust the function parameters, or apply them in a rapid sequence. We learned that mostly, these transform functions can only be applied to elements individually, with only the last to be defined being applied. The matrix function however allows us to apply several of the functions to a single element. We can't rotate and skew a single element, but we can rotate, scale, and translate an element, or skew, scale, and translate it if we wish. Browser support for CSS3 transforms is very good, with only very minor differences between most browsers (such as the translate values being in pixels for Firefox and unit-less for Webkitbased browsers and Opera) except IE. IE does have its own proprietary implementation of the different transforms, although these are not implemented in a particularly useful way, such as not being able to translate elements if we don't want those same elements to be clipped. We can only hope that IE9, recently released as a beta product, will handle them better. In addition to CSS3 transforms, a CSS3 transitions specification has also been proposed, which would allow us to transition elements between different transform states using pure CSS, without the need for animating them with JavaScript at all. We didn't look at these at all in this chapter because support for them is restricted to just Webkit-based browsers or Opera at the time of writing. Beta versions of Firefox and IE also have support for them, but we have dealt only with fully-released browsers throughout the book. We saw that although we can't use the transform functions in jQuery's animate() method, we can easily create our own animations manually, and we can use them with other methods, such as the css() method. Don't forget about using cssHooks to achieve this kind of functionality too. In the next and final chapter of the book, we'll take a look at a new HTML5 element that allows us pixel-perfect control over an area on the page—the element—and how it can be used to create interactive animations. [ 264 ]
- Page 234 and 235: [ 213 ] Chapter 8 In the previous s
- Page 236 and 237: prox.mousemove(function(ev) { goAni
- Page 238 and 239: Pop quiz - implementing proximity a
- Page 240 and 241: [ 219 ] Chapter 8 What just happene
- Page 242 and 243: 2. Save the new page as marquee.htm
- Page 244 and 245: [ 223 ] Chapter 8 1. jQuery provide
- Page 246 and 247: clear:both; } div#fadeLeft, div#fad
- Page 248 and 249: Time for action - animating the pos
- Page 250: 2. In this example we used the dele
- Page 253 and 254: CSS3 Animations The following trans
- Page 255 and 256: CSS3 Animations Units It is of crit
- Page 257 and 258: CSS3 Animations Skew Remember the t
- Page 259 and 260: CSS3 Animations Calculating the sin
- Page 261 and 262: CSS3 Animations The filter property
- Page 263 and 264: CSS3 Animations If, like me, you th
- Page 265 and 266: CSS3 Animations } el.filters.item("
- Page 267 and 268: CSS3 Animations An unfortunate prob
- Page 269 and 270: CSS3 Animations The context of this
- Page 271 and 272: CSS3 Animations Time for action - i
- Page 273 and 274: CSS3 Animations The first variable
- Page 275 and 276: CSS3 Animations Time for action - a
- Page 277 and 278: Download from Wow! eBook CSS3 Anim
- Page 279 and 280: CSS3 Animations We also have to upd
- Page 281 and 282: CSS3 Animations flatMatrix[3] = fla
- Page 283: CSS3 Animations When updating the s
- Page 287 and 288: Canvas Animations Subjects that we'
- Page 289 and 290: Canvas Animations We can set the co
- Page 291 and 292: Download from Wow! eBook Canvas An
- Page 293 and 294: Canvas Animations All imageData obj
- Page 295 and 296: Canvas Animations context.beginPath
- Page 297 and 298: Canvas Animations For the next part
- Page 299 and 300: Canvas Animations Time for action -
- Page 301 and 302: Canvas Animations 3. Save the new p
- Page 303 and 304: Canvas Animations Time for action -
- Page 305 and 306: Canvas Animations Once the rectangl
- Page 307 and 308: Canvas Animations We then define tw
- Page 309 and 310: Canvas Animations }, context.lineTo
- Page 311 and 312: Canvas Animations Creating a canvas
- Page 313 and 314: Canvas Animations Time for action -
- Page 315 and 316: Canvas Animations What just happene
- Page 317 and 318: Canvas Animations What just happene
- Page 319 and 320: Canvas Animations aliens.splice(x,
- Page 321 and 322: Canvas Animations Pop quiz - creati
- Page 323 and 324: Download from Wow! eBook
- Page 325 and 326: Pop Quiz Answers Using fadeToggle()
- Page 327 and 328: Pop Quiz Answers Using slideToggle
- Page 329 and 330: Pop Quiz Answers Implementing the p
- Page 331 and 332: Pop Quiz Answers Animating the canv
- Page 333 and 334: show() or hide() method, triggering
CSS3 <strong>Animation</strong>s<br />
translate<br />
translateX<br />
translateY<br />
We learned a lot about the new CSS3 matrix property in this chapter, as well as how to<br />
make use <strong>of</strong> it with <strong>jQuery</strong>. Specifically, we learned the following:<br />
We first saw the different values that these functions take and the effects that they<br />
have on elements they are applied to.<br />
We also saw that in order to animate these styles, we can use simple native<br />
JavaScript intervals or timeouts to continuously adjust the function parameters,<br />
or apply them in a rapid sequence.<br />
We learned that mostly, these transform functions can only be applied to elements<br />
individually, with only the last to be defined being applied. The matrix function<br />
however allows us to apply several <strong>of</strong> the functions to a single element.<br />
We can't rotate and skew a single element, but we can rotate, scale, and translate<br />
an element, or skew, scale, and translate it if we wish. Browser support for CSS3<br />
transforms is very good, with only very minor differences between most browsers<br />
(such as the translate values being in pixels for Firefox and unit-less for Webkitbased<br />
browsers and Opera) except IE.<br />
IE does have its own proprietary implementation <strong>of</strong> the different transforms,<br />
although these are not implemented in a particularly useful way, such as not being<br />
able to translate elements if we don't want those same elements to be clipped. We<br />
can only hope that IE9, recently released as a beta product, will handle them better.<br />
In addition to CSS3 transforms, a CSS3 transitions specification has also been<br />
proposed, which would allow us to transition elements between different transform<br />
states using pure CSS, without the need for animating them with JavaScript at all.<br />
We didn't look at these at all in this chapter because support for them is restricted<br />
to just Webkit-based browsers or Opera at the time <strong>of</strong> writing. Beta versions <strong>of</strong><br />
Firefox and IE also have support for them, but we have dealt only with fully-released<br />
browsers throughout the book.<br />
We saw that although we can't use the transform functions in <strong>jQuery</strong>'s animate()<br />
method, we can easily create our own animations manually, and we can use them<br />
with other methods, such as the css() method. Don't forget about using cssHooks<br />
to achieve this kind <strong>of</strong> functionality too.<br />
In the next and final chapter <strong>of</strong> the book, we'll take a look at a new HTML5 element that<br />
allows us pixel-perfect control over an area on the page—the element—and how<br />
it can be used to create interactive animations.<br />
[ 264 ]