Skip to content

Instantly share code, notes, and snippets.

@ktroye
Created July 16, 2013 11:31
Show Gist options
  • Select an option

  • Save ktroye/6007943 to your computer and use it in GitHub Desktop.

Select an option

Save ktroye/6007943 to your computer and use it in GitHub Desktop.
Javascript: Fading elements
$.fn.fadeAll = function (ops) {
var o = $.extend({
delay: 500, // delay between elements
speed: 500, // animation speed
ease: 'swing' // other require easing plugin
}, ops);
var $el = this;
for (var i=0, d=0, l=$el.length; i<l; i++, d+=o.delay) {
$el.eq(i).delay(d).fadeIn(o.speed, o.ease);
}
return $el;
}
$(elements).fadeAll({ delay: 300, speed: 300 });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment