Created
December 20, 2011 03:49
-
-
Save Radagaisus/1500144 to your computer and use it in GitHub Desktop.
Yellow Fade Technique in Coffee
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
# $(".something").yellow_fade(1000) | |
# underscore.js is used. adapted from http://amix.dk/blog/post/19029 | |
(($) -> | |
$.fn.yellow_fade = (speed) -> | |
# we call this function repeatedly | |
decrease_fade = (e, i, speed) -> | |
shades = ['ff', 'ee', 'dd', 'cc', 'bb', 'aa', '99'] | |
if i # i == 0 | |
e.css 'backgroundColor', "#ffff#{shades[i]}" | |
_.delay decrease_fade, speed, e, i-1, speed | |
else | |
e.css 'backgroundColor', 'transparent' | |
@each -> | |
decrease_fade $(@), 6, speed | |
)(jQuery) | |
# Javascript: | |
(function($) { | |
$.fn.yellow_fade = function(speed) { | |
var decrease_fade = function(e, i, speed) { | |
var shades = ['ff', 'ee', 'dd', 'cc', 'bb', 'aa', '99']; | |
if (i) { | |
e.css('backgroundColor', "#ffff" + shades[i]); | |
_.delay(decrease_fade, speed, e, i - 1, speed); | |
} else { | |
e.css('backgroundColor', 'transparent'); | |
} | |
}; | |
return this.each(function() { | |
decrease_fade($(this), 6, speed); | |
}); | |
}})(jQuery) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment