Created
February 1, 2013 13:01
-
-
Save octan3/4691177 to your computer and use it in GitHub Desktop.
Animate the backgroundColor-opacity-value.
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
$.fx.step.backgroundColor = function(fx) { | |
if (!fx._init) { | |
// parse RGBA-Color | |
var col = /\((\d+,\s*\d+,\s*\d+),\s*([\d\.]+)\s*\)/.exec($.css(fx.elem, 'backgroundColor')); | |
// set correct start-value | |
fx.start = parseFloat(col[2]); | |
// remember background-color | |
fx._baseColor = col[1]; | |
// run only once | |
fx._init = true; | |
} | |
// do the job | |
fx.elem.style.backgroundColor = 'rgba(' + fx._baseColor + ', ' + fx.now + ')'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment