2 Copyright (c) 2010, Yahoo! Inc. All rights reserved.
3 Code licensed under the BSD License:
4 http://developer.yahoo.com/yui/license.html
8 YUI.add('anim-color', function(Y) {
11 * Adds support for color properties in <code>to</code>
12 * and <code>from</code> attributes.
14 * @submodule anim-color
19 Y.Anim.behaviors.color = {
20 set: function(anim, att, from, to, elapsed, duration, fn) {
21 from = Y.Color.re_RGB.exec(Y.Color.toRGB(from));
22 to = Y.Color.re_RGB.exec(Y.Color.toRGB(to));
24 if (!from || from.length < 3 || !to || to.length < 3) {
25 Y.error('invalid from or to passed to color behavior');
28 anim._node.setStyle(att, 'rgb(' + [
29 Math.floor(fn(elapsed, NUM(from[1]), NUM(to[1]) - NUM(from[1]), duration)),
30 Math.floor(fn(elapsed, NUM(from[2]), NUM(to[2]) - NUM(from[2]), duration)),
31 Math.floor(fn(elapsed, NUM(from[3]), NUM(to[3]) - NUM(from[3]), duration))
35 // TODO: default bgcolor const
36 get: function(anim, att) {
37 var val = anim._node.getComputedStyle(att);
38 val = (val === 'transparent') ? 'rgb(255, 255, 255)' : val;
43 Y.each(['backgroundColor',
50 Y.Anim.behaviors[v] = Y.Anim.behaviors.color;
55 }, '3.3.0' ,{requires:['anim-base']});