SLIDE 28 jQuery ¡Effects: ¡animate ¡
Create ¡custom ¡animaOons ¡ ¡ Syntax: ¡toggle ¡between ¡the ¡hide() ¡and ¡show() ¡ ¡
- $(selector).animate({params},speed,callback); ¡
¡<script> ¡
¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡$(document).ready(funcTon(){ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡$("bu8on").click(funcTon(){ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡$("div").animate({ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡les:'250px’, ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡opacity:'0.5’, ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡height:'150px’, ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡width:'150px’ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡}, ¡5000, ¡funcTon() ¡{alert("done")} ¡); ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡}); ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡}); ¡ ¡ ¡ ¡ ¡</script> ¡
28
jQueryAnimate.html
Using relative values: var $square = $("#square"); function bounce() { $square.animate({ top: "+=10" }, 300, function() { $square.animate({ top: "-=10" }, 300, function() { bounce(); }) }); } $(document).ready(function(){ bounce(); });
Also: continuousAnimationJQ.html