Skip to content

Instantly share code, notes, and snippets.

@cfleschhut cfleschhut/yft.js
Created May 22, 2011

Embed
What would you like to do?
“Yellow Fade Technique” (Bulletproof Ajax)
/* Demo: http://jsfiddle.net/HdMMj/ */
function fadeUp(element, red, green, blue) {
if (element.fade) clearTimeout(element.fade);
element.style.backgroundColor = "rgb(" + red + ", " + green + ", " + blue + ")";
if (red == 255 && green == 255 && blue == 255) return;
var newred = red + Math.ceil((255 - red)/10);
var newgreen = green + Math.ceil((255 - green)/10);
var newblue = blue + Math.ceil((255 - blue)/10);
element.fade = setTimeout(function() {
fadeUp(element, newred, newgreen, newblue);
}, 50);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.