Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@cfleschhut
Created May 22, 2011 21:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cfleschhut/985924 to your computer and use it in GitHub Desktop.
Save cfleschhut/985924 to your computer and use it in GitHub Desktop.
“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