vinod's erudition

we learn everything from failure not from success so keep failing

Home Ruby Rails Javascript Python Agentic AI

animate-box is simple and cool

Posted on March 19, 2014 by vinod

today because of loads of work ,will play with simple application where there will be couple of square shaped boxes where when it is clicked it will animated(flip,crawl,dangle,stretch,jump).

####Explanation:

github link: https://github.com/vxvinod/javascript-oath/tree/master/exercise-6-animate-box

####Javascript file below

(function(){

	var animations=['crawl','dangle','flip','stretch','jump'];
	$('.box').on('click',function(){
		var ths = $(this);
		var anim = animations[Math.floor(Math.random()*5)];
		console.log(anim);
		$(ths).addClass(anim);
		setTimeout(function(){
			$(ths).removeClass(anim);
		},5000);
	});
})();