Animate Color using Jquery
I found one other solution - It can be done by including jQuery UI.Lets see which one is better.
We are taking an example of SuperNova Animation with Jquery, It works on background color animation.
Animate Color using jQuery UI
You can load Jquery UI with help of Google's AJAX API<!-- include Google's AJAX API loader--> <script src="http://www.google.com/jsapi"></script>
<!-- load JQuery and UI from Google (need to use UI to animate colors) --><script type="text/javascript"> //nova function
function nova(){ //generating random rgb color
var color = 'rgb("+ Math.floor(Math.random()*255)+","+ Math.floor(Math.random()*255)+","+ Math.floor(Math.random()*255)+")';
$(document.body).animate({ //animate background color
backgroundColor:color
}, 1000); //Setting up timeout, It calls itself after given time
window.setTimeout("nova()",1100);
}
$(document).ready(function() { //Calling nova first timenova(); });</script>
Animate Color using jQuery color animations plugin.
Here is an example how to use it:
$(this).animate({ backgroundColor: "#f6f6f6" }, "fast");
Which one it better?
The color plugin is only 4kb, easy to load than the UI library.but it doesnt support rgb colors. The color plugin has issues with Safari and Chrome. It only works sometimes, jQuery UI version works on all browsers.I think using jQuery UI is better than Color Plugin. Its working well for me.
Demo
You can see the working demo of SuperNova Animation here.
Labels: Animation, css, jquery, Tutorials
By : Motyar+ @motyar4 comments
says…
All other tutorials of this site are also very useful, thanx for sharing such a great ideas.
I really love this on - http://motyar.blogspot.com/2010/03/page-curl-fold-or-peel-effect-with-pure.html
Dharmveer Motyar says…
Thanx for your love. keep reading!!
says…
creanónimo says…
Do your know if it works with the the colour alpha property. rgba values?
Peace


Post a Comment