jQuery 1.4 Animation Techniques - Index of
jQuery 1.4 Animation Techniques - Index of jQuery 1.4 Animation Techniques - Index of
7 Full Page Animations So far the examples that we've looked at are animations that have formed a single part of the user interface of the page, or formed part of a specific widget. In this chapter, we'll look at animations that take up the whole page, such as background-image animations, or "feature" animations where the thing being animated is the main focus of the page. In this chapter, we'll cover the following subjects: Animating page scroll Animating background-position to create a parallax effect Combining page scroll with page navigation Creating stop-motion animation All of the examples that we'll look at in this chapter will be based on the animate() method that was introduced earlier in the book. As we've already learnt how the method is used, we can jump straight into the action and start on the examples. Animated page scroll We can animate the scroll of the entire page very easily using a combination of some built-in jQuery functionality and some plain vanilla JavaScript. Long blog pages are often split into smaller, more readable sections with sub-headings, and a secondary navigation structure, separate from the main site navigation, which links to the different sections. Optionally, there may also be back to top links that take the reader back up to the top of the page.
Full Page Animations Can we animate the scroll using jQuery's animate() method so that the document scrolls smoothly instead of jumping to the desired location when any of these links are clicked? Not exactly—the scrollTop() method that jQuery exposes cannot be used directly in conjunction with the animate() method. But we can spoof the animation effect ourselves manually and make it appear as if the scroll is animated very easily, which is what we'll do in the first example of this chapter. Time for action – creating the page that will scroll and its styling The example page needs to be quite long for the scroll effect to work. The underlying HTML used could be any modern blog post. 1. Add the following code to the of the template file: A long article with lots of sections Section 1 Section 2 Section 3 Section 4 Section 5 Posted on 13 November 2010 by Dan Wellman Section 1 Lorem ipsum dolor... Lorem ipsum dolor... Back to top [ 180 ]
- Page 150 and 151: [ 129 ] Chapter 5 Once we've define
- Page 152 and 153: } }; $(config.selector).find("a").c
- Page 154 and 155: [ 133 ] Chapter 5 In the previous s
- Page 156: Have a go hero - extending the plug
- Page 159 and 160: Extended Animations with jQuery UI
- Page 161 and 162: Extended Animations with jQuery UI
- Page 163 and 164: Extended Animations with jQuery UI
- Page 165 and 166: Extended Animations with jQuery UI
- Page 167 and 168: Extended Animations with jQuery UI
- 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: Extended Animations with jQuery UI
- 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 and 220: Full Page Animations The second sec
- Page 221 and 222: Full Page Animations Pop quiz - cre
- 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
Full Page <strong>Animation</strong>s<br />
Can we animate the scroll using <strong>jQuery</strong>'s animate() method so that the document scrolls<br />
smoothly instead <strong>of</strong> jumping to the desired location when any <strong>of</strong> these links are clicked?<br />
Not exactly—the scrollTop() method that <strong>jQuery</strong> exposes cannot be used directly in<br />
conjunction with the animate() method.<br />
But we can spo<strong>of</strong> the animation effect ourselves manually and make it appear as if the scroll<br />
is animated very easily, which is what we'll do in the first example <strong>of</strong> this chapter.<br />
Time for action – creating the page that will scroll<br />
and its styling<br />
The example page needs to be quite long for the scroll effect to work. The underlying HTML<br />
used could be any modern blog post.<br />
1. Add the following code to the <strong>of</strong> the template file:<br />
<br />
<br />
A long article with lots <strong>of</strong> sections<br />
<br />
<br />
<br />
Section 1<br />
<br />
Section 2<br />
<br />
Section 3<br />
<br />
Section 4<br />
<br />
Section 5<br />
<br />
<br />
Posted on <br />
13 November 2010 by Dan Wellman<br />
<br />
<br />
Section 1<br />
Lorem ipsum dolor...<br />
Lorem ipsum dolor...<br />
<br />
Back to top<br />
<br />
<br />
[ 180 ]