This demonstrates how to animate color attributes.
Mouse over the link to begin the animation.
First we add some HTML to animate.
``` hover me ```Now we create an instance of Y.Anim
, passing it a configuration object that includes the node
we wish to animate and the to
attribute containing the final properties and their values.
Adding a from
attribute allows us to reset the colors onmouseout
using the reverse
attribute, which we will see below.
Next we need a handler to run when the link is moused over, and reverse when moused out.
``` var hover = function(e) { var reverse = false; if (anim.get('running')) { anim.pause(); } if (e.type === 'mouseout') { reverse = true; } anim.set('reverse', reverse); anim.run(); }; ```Finally we add an event handler to run the animation.
``` node.on('mouseover', hover); node.on('mouseout', hover); ```