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.

[ 193 ]<br />

Chapter 7<br />

As the screenshot shows, the page still works and the site can be navigated with JavaScript<br />

disabled. Some <strong>of</strong> our styling is added with JavaScript (via class name additions), so the final<br />

page will appear slightly differently.<br />

What just happened?<br />

The underlying HTML is fairly straight-forward and just represents a simple collection <strong>of</strong><br />

example elements including header and footer navigation. The styles are also very light and<br />

are there mostly just to lay out the example pages. The rules at the bottom <strong>of</strong> the file are for<br />

elements or classes that are added dynamically by the script.<br />

The previous screenshot shows how the page will appear to those with scripting disabled,<br />

although it is very similar to how the page will appear once we've added the script, which<br />

we'll do next.<br />

Time for action – adding the scroll navigation<br />

In this section we will add the code that will enable animated scrolling.<br />

1. In another new file in your text editor, add the following code (it should go into a<br />

empty function which aliases the $ character, the same as in the other examples):<br />

$("#content").empty();<br />

var win = $(window),<br />

links = $("header nav a"),<br />

content = $("#content"),<br />

positions = {},

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

Saved successfully!

Ooh no, something went wrong!