jQuery 1.4 Animation Techniques - Index of
jQuery 1.4 Animation Techniques - Index of jQuery 1.4 Animation Techniques - Index of
[ 199 ] Chapter 7 We then set the href of the current link to a document fragment identifier pointing to the name of the corresponding content section. This wouldn't have any effect if we weren't intercepting clicks on the nav links because the content sections don't have matching id attributes, but it is necessary to store the fragment here so that we can read it back when the link is clicked. Lastly, we check again whether we're processing the last link or not, and if we are, we trigger our custom contentLoaded event, which results in the page's element being appended to the page, and the click handlers bound to the navigation links. Building a site like this which pulls all of its content into a single page won't suit every type of site. Most clients would probably pay the cancellation fees and swiftly withdraw if this idea was presented to them. However, on highly stylized sites, where the design and behavior of the site is of special importance, this kind of effect can work well. Sites with little content on each page are especially suited to it. The following screenshot shows the functionality in action: In the previous screenshot, we can see the header and footer partly faded out, and the page content being scrolled diagonally downwards to the right.
Full Page Animations Pop quiz – creating a single-page website 1. We interact with the this object directly in this example instead of the jQuery equivalent $(this), why? a. Because it uses fewer characters b. Its faster and more efficient because an entirely new jQuery object is not created c. Because it looks better d. Because it contains more information 2. We create and use a custom event in this example, why? a. Because custom events execute faster than standard browser events b. Because the each() method does not allow us to update the scrollTop property of the window c. Because it is more efficient for the code executed by the handler to be called once than on every iteration of the each() method d. Because the scrollTo plugin can only be used in conjunction with custom events Have a go hero – extending single-page navigation There are several things you could do to expand on this example. One thing you could do is add functionality that checks which page is requested by looking at the href property of the document. If a page other than the first page is requested, you could scroll to the corresponding page section so that the page they link to is actually shown instead of resetting to the first page. Another thing you could do would be to extend the example so that the pages don't have to be numbered page-2.html, and so on, and instead could have any file name. In the first section of code, we read the href of the link if one of the footer links is clicked instead of looking for a document fragment identifier. This same technique could be applied to the header links as well, so that any page that is linked to can be included in the single page. Or, to really appreciate the visual effect of our site-on-a-page, you could add some additional content and a theme to the site. Each page need not have the same skin, and scrolling between different colors and imagery can really bring the page to life. [ 200 ]
- Page 169 and 170: Extended Animations with jQuery UI
- Page 171 and 172: Download from Wow! eBook Extended
- Page 173 and 174: Extended Animations with jQuery UI
- Page 175 and 176: Extended Animations with jQuery UI
- Page 177 and 178: Extended Animations with jQuery UI
- Page 179 and 180: Extended Animations with jQuery UI
- Page 181 and 182: Extended Animations with jQuery UI
- Page 183 and 184: Extended Animations with jQuery UI
- Page 185 and 186: Extended Animations with jQuery UI
- Page 187 and 188: Extended Animations with jQuery UI
- Page 189 and 190: Extended Animations with jQuery UI
- Page 191 and 192: Extended Animations with jQuery UI
- Page 193 and 194: Extended Animations with jQuery UI
- Page 195 and 196: Extended Animations with jQuery UI
- Page 197 and 198: Extended Animations with jQuery UI
- Page 199 and 200: Extended Animations with jQuery UI
- Page 201 and 202: Full Page Animations Can we animate
- Page 203 and 204: Full Page Animations display:block;
- Page 205 and 206: Download from Wow! eBook Full Page
- Page 207 and 208: Full Page Animations Have a go hero
- Page 209 and 210: Full Page Animations 4. Save this f
- Page 211 and 212: Full Page Animations 2. The bgpos c
- Page 213 and 214: Full Page Animations nav ul { margi
- Page 215 and 216: Full Page Animations screensize = {
- Page 217 and 218: Full Page Animations What just happ
- Page 219: Full Page Animations The second sec
- Page 223 and 224: Full Page Animations Time for actio
- Page 225 and 226: Full Page Animations Next we define
- Page 228 and 229: 8 Other Popular Animations This cha
- Page 230 and 231: [ 209 ] Chapter 8 } .slider #scroll
- Page 232 and 233: }), pointerText = "Use your pointer
- 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
Full Page <strong>Animation</strong>s<br />
Pop quiz – creating a single-page website<br />
1. We interact with the this object directly in this example instead <strong>of</strong> the <strong>jQuery</strong><br />
equivalent $(this), why?<br />
a. Because it uses fewer characters<br />
b. Its faster and more efficient because an entirely new <strong>jQuery</strong> object is not<br />
created<br />
c. Because it looks better<br />
d. Because it contains more information<br />
2. We create and use a custom event in this example, why?<br />
a. Because custom events execute faster than standard browser events<br />
b. Because the each() method does not allow us to update the scrollTop<br />
property <strong>of</strong> the window<br />
c. Because it is more efficient for the code executed by the handler to be called<br />
once than on every iteration <strong>of</strong> the each() method<br />
d. Because the scrollTo plugin can only be used in conjunction with<br />
custom events<br />
Have a go hero – extending single-page navigation<br />
There are several things you could do to expand on this example. One thing you could do<br />
is add functionality that checks which page is requested by looking at the href property<br />
<strong>of</strong> the document. If a page other than the first page is requested, you could scroll to the<br />
corresponding page section so that the page they link to is actually shown instead <strong>of</strong><br />
resetting to the first page.<br />
Another thing you could do would be to extend the example so that the pages don't have<br />
to be numbered page-2.html, and so on, and instead could have any file name. In the<br />
first section <strong>of</strong> code, we read the href <strong>of</strong> the link if one <strong>of</strong> the footer links is clicked instead<br />
<strong>of</strong> looking for a document fragment identifier. This same technique could be applied to the<br />
header links as well, so that any page that is linked to can be included in the single page.<br />
Or, to really appreciate the visual effect <strong>of</strong> our site-on-a-page, you could add some additional<br />
content and a theme to the site. Each page need not have the same skin, and scrolling<br />
between different colors and imagery can really bring the page to life.<br />
[ 200 ]