02.06.2013 Views

jQuery 1.4 Animation Techniques - Index of

jQuery 1.4 Animation Techniques - Index of

jQuery 1.4 Animation Techniques - Index of

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Pop quiz – implementing proximity animations<br />

[ 217 ]<br />

Chapter 8<br />

1. We provided additional functionality by adding keyboard navigability in the previous<br />

example, why?<br />

a. For fun<br />

b. To look good<br />

c. To provide an alternate way for the content to be explored by<br />

non-mouse users<br />

d. Keyboard events must be bound whenever mouse events are used<br />

2. Why should we avoid hardcoding 'magic' numbers into our scripts?<br />

a. To make our code more readable<br />

b. So that our scripts are less reliant on the content that they act upon<br />

c. hardcoded integers take longer to process<br />

d. Because <strong>jQuery</strong> prefers working with strings<br />

Animated page headers<br />

Another quite fashionable technique at the moment is to have an animation that runs in the<br />

header <strong>of</strong> the page when the home page loads. Sometimes the animations run continually<br />

on every page <strong>of</strong> the site; others run once on the home page only.<br />

This technique is an easy and effective way to make your site stand out, and they needn't be<br />

complex or heavily apparent animations; a short, subtle animation can be enough to add the<br />

wow factor.<br />

Earlier in the book we looked at using the new cssHooks functionality in conjunction with a<br />

pre-written file that makes use <strong>of</strong> cssHooks, which extends <strong>jQuery</strong>'s css() method to allow<br />

an element's background-position style property to be animated. In this example, we'll<br />

look at how we can do this manually without the use <strong>of</strong> the plugin.<br />

Well-written plugins can be an effective and easy solution, but there are times when a plugin<br />

adds much more functionality than we actually need and therefore increase a page's script<br />

overhead. It's not <strong>of</strong>ten that reinventing the wheel is necessary or advised, but there can be<br />

times when it's beneficial to write a custom script that does only what we require.

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

Saved successfully!

Ooh no, something went wrong!