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.

[ 171 ]<br />

Chapter 6<br />

2. The script we need is a little longer, but is still pretty simple. In the empty function at<br />

the end <strong>of</strong> the page add the following code:<br />

$("img").click(function() {<br />

var img = $(this);<br />

if(!img.hasClass("full")) {<br />

img.addClass("full").effect("scale", { percent: 400 },<br />

function() {<br />

$("", {<br />

href: "#",<br />

text: "x",<br />

click: function(e) {<br />

e.preventDefault;<br />

var a = $(this);<br />

a.parent().find("img").removeClass("full").effect("scale", {<br />

percent: 25 });<br />

a.remove();<br />

}<br />

}).appendTo("#container");<br />

});<br />

};<br />

});<br />

3. Save the page as scale.html. In the stylesheet for this example, we'll need the<br />

following code:<br />

#container { position:relative; float:left; cursor:pointer; }<br />

#container img { width:150px; height:150px; }<br />

#container a {<br />

position:absolute; top:0; right:10px; color:#f21515;<br />

text-decoration:none; font:bold 22px "Nimbus Sans L", "Helvetica<br />

Neue", "Franklin Gothic Medium", Sans-serif;<br />

}<br />

#container a:hover { color:#fb5e5e; }<br />

4. Save this file as scale.css.

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

Saved successfully!

Ooh no, something went wrong!