Skip to content

Instantly share code, notes, and snippets.

@builtbylane
Last active October 14, 2019 19:45
Show Gist options
  • Save builtbylane/7462086 to your computer and use it in GitHub Desktop.
Save builtbylane/7462086 to your computer and use it in GitHub Desktop.
jQuery: add class to each item incrementally... good for fading in blocks
$(function() {
'use strict';
// deps... jquery
var $fade_this_in = $('.something-with-opacity-0');
function laneAddClassDelay(jquerobj, theclass, theinterval) {
setTimeout(function() {
jquerobj.addClass(theclass);
}, theinterval);
}
// fade in each thumb incrementally
$fade_this_in.each(function(i) {
laneAddClassDelay($(this), 'fadein', 200 * i);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment