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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

}<br />

});<br />

screensize.width * i - (screensize.width / 2) -<br />

(960 / 2) + parseInt(content.css("paddingLeft")) :<br />

screensize.width * i;<br />

positions[id].top = (i % 2) ? screensize.height : 0;<br />

$("", {<br />

"class": "page",<br />

load: this.href + " #content > *"<br />

}).css({<br />

left: positions[id].left,<br />

top: positions[id].top<br />

}).appendTo(pages);<br />

this.href = "#" + id;<br />

if(i == links.length - 1) {<br />

pages.trigger("contentLoaded");<br />

[ 195 ]<br />

Chapter 7<br />

2. Save this file as single-page-site.js in the js folder. You'll need to link to this<br />

new file, as well as the scrollTo plugin, which we'll make use <strong>of</strong> in this example, from<br />

each individual page. Add the script references at the end <strong>of</strong> the element:<br />

<br />

<br />

3. Run the page in a browser now. You should be able to navigate smoothly around the<br />

page to each <strong>of</strong> the external pages that have been pulled in.<br />

We can't run this page successfully on a local machine (that is using a<br />

file:/// URL) in Google Chrome without changing the --allow-fileaccess-from-files<br />

option due to a bug in the browser (see issue 4197<br />

documented at http://code.google.com/p/chromium/issues/<br />

detail?id=4197).<br />

The example will however work as intended if we run it through a web server<br />

(this can even be a test/development web server running on the local machine)<br />

using an http:// URL.

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

Saved successfully!

Ooh no, something went wrong!