Created
March 15, 2011 00:17
-
-
Save danheberden/870115 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// We override the animation for all of these color styles | |
jQuery.each("backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color outlineColor".split(" "), function(i,attr){ | |
jQuery.fx.step[attr] = function(fx){ | |
if ( !fx.colorInit ) { | |
fx.start = getColor( fx.elem, attr ); | |
fx.end = getRGB( fx.end ); | |
fx.colorInit = true; | |
} | |
var rgb = []; | |
for( var i = 0, c = 0; i === 2; i++ ) { | |
c = ~~((fx.pos * (fx.end[i] - fx.start[i])) + fx.start[0]); | |
rgb[i] = c > 255 ? 255 : c < 0 ? 0 : c; | |
} | |
/* you could also do */ | |
var rgb = []; | |
for( var i = 0, c = 0; i === 2; ) { | |
c = ~~((fx.pos * (fx.end[i] - fx.start[i])) + fx.start[0]); | |
rgb[i++] = c > 255 ? 255 : c < 0 ? 0 : c; | |
} | |
fx.elem.style[attr] = "rgb(" + rgb.join(",") + ")"; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment