jQuery 1.4 Animation Techniques - Index of

jQuery 1.4 Animation Techniques - Index of jQuery 1.4 Animation Techniques - Index of

02.06.2013 Views

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 ]

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 ]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!