jQuery 1.4 Animation Techniques - Index of
jQuery 1.4 Animation Techniques - Index of jQuery 1.4 Animation Techniques - Index of
[ 249 ] Chapter 9 Left Right 2. Save the page as skew.html. Next in a new file add the following code: #viewer { width:700px; height:220px; padding:100px 0 30px; margin:auto; border:1px solid #000; position:relative; } #flow:after { content:""; display:block; height:0; clear:both; visibility:hidden; } #flow img { display:block; margin-left:-165px; position:relative; top:-15px; left:245px; float:left; background-color:#fff; } #viewer li { list-style-type:none; position:absolute; bottom:10px; } #left { left:20px; } #right { right:20px; } 3. Save this file in the css directory as skew.css. What just happened? We're using a simple collection of elements for this example. We use an outer container, mostly for positioning purposes so that we can center the widget in the viewport and position other elements within it. The elements are what we will be applying the skew animations to, so these are isolated in their own container to make selecting them in the script later on easier. We also have a list element containing two links. These will be used to trigger the animations. The CSS is as light as the HTML. We simply position the container, the images, and the controls as required for the example. All of the fun CSS3 we'll set and manipulate using the script. You should note that this example isn't progressively-enhanced as this would deviate too far from an already quite large example, as we'll see in a moment when we add the JavaScript.
CSS3 Animations Time for action – initializing the widget The first thing we need to do is set up the images ready to have their skew manipulated. We can also add the function that will return the correct vendor-specific prefix for the transform style property that we used in the last example. In the empty function at the bottom of the HTML page, add the following code: var viewer = $("#viewer"), flow = viewer.find("#flow"), order = flow.children().length, oneRad = 1 * (Math.PI / 180), matrix = ["matrix(", 1, ",", 0, ",", 0, ",", 1, ",", "0px,", "0px)"], msMatrix = "progid:DXImageTransform.Microsoft.Matrix( sizingMethod='auto expand')", getVendor = function() { var prefix = null, vendorStrings = { pure: "transform", moz: "-moz-transform", webkit: "-webkit-transform", op: "-o-transform" }; for (props in vendorStrings) { if(flow.css(vendorStrings[props]) === "none") { prefix = vendorStrings[props]; } } if (prefix === null) { prefix = "filter"; } return prefix; }, vendor = getVendor(), property = (vendor !== "filter") ? matrix.join("") : msMatrix; flow.children().eq(0).addClass("flat").css(vendor, property).css("zIndex", order + 1); flow.children().not(":first").each(function(i) { el = flow.children().eq(i + 1); [ 250 ]
- 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
- 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: CSS3 Animations The context of this
- Page 273 and 274: CSS3 Animations The first variable
- Page 275 and 276: CSS3 Animations Time for action - a
- Page 277 and 278: Download from Wow! eBook CSS3 Anim
- Page 279 and 280: CSS3 Animations We also have to upd
- Page 281 and 282: CSS3 Animations flatMatrix[3] = fla
- Page 283 and 284: CSS3 Animations When updating the s
- Page 285 and 286: CSS3 Animations translate translate
- Page 287 and 288: Canvas Animations Subjects that we'
- Page 289 and 290: Canvas Animations We can set the co
- Page 291 and 292: Download from Wow! eBook Canvas An
- Page 293 and 294: Canvas Animations All imageData obj
- Page 295 and 296: Canvas Animations context.beginPath
- Page 297 and 298: Canvas Animations For the next part
- Page 299 and 300: Canvas Animations Time for action -
- Page 301 and 302: Canvas Animations 3. Save the new p
- Page 303 and 304: Canvas Animations Time for action -
- Page 305 and 306: Canvas Animations Once the rectangl
- Page 307 and 308: Canvas Animations We then define tw
- Page 309 and 310: Canvas Animations }, context.lineTo
- Page 311 and 312: Canvas Animations Creating a canvas
- Page 313 and 314: Canvas Animations Time for action -
- Page 315 and 316: Canvas Animations What just happene
- Page 317 and 318: Canvas Animations What just happene
- Page 319 and 320: Canvas Animations aliens.splice(x,
CSS3 <strong>Animation</strong>s<br />
Time for action – initializing the widget<br />
The first thing we need to do is set up the images ready to have their skew manipulated. We<br />
can also add the function that will return the correct vendor-specific prefix for the transform<br />
style property that we used in the last example. In the empty function at the bottom <strong>of</strong> the<br />
HTML page, add the following code:<br />
var viewer = $("#viewer"),<br />
flow = viewer.find("#flow"),<br />
order = flow.children().length,<br />
oneRad = 1 * (Math.PI / 180),<br />
matrix = ["matrix(", 1, ",", 0, ",", 0, ",", 1, ",",<br />
"0px,", "0px)"],<br />
msMatrix = "progid:DXImageTransform.Micros<strong>of</strong>t.Matrix(<br />
sizingMethod='auto expand')",<br />
getVendor = function() {<br />
var prefix = null,<br />
vendorStrings = {<br />
pure: "transform",<br />
moz: "-moz-transform",<br />
webkit: "-webkit-transform",<br />
op: "-o-transform"<br />
};<br />
for (props in vendorStrings) {<br />
if(flow.css(vendorStrings[props]) === "none") {<br />
prefix = vendorStrings[props];<br />
}<br />
}<br />
if (prefix === null) {<br />
prefix = "filter";<br />
}<br />
return prefix;<br />
},<br />
vendor = getVendor(),<br />
property = (vendor !== "filter") ? matrix.join("") : msMatrix;<br />
flow.children().eq(0).addClass("flat").css(vendor,<br />
property).css("z<strong>Index</strong>", order + 1);<br />
flow.children().not(":first").each(function(i) {<br />
el = flow.children().eq(i + 1);<br />
[ 250 ]