Skip to content

Instantly share code, notes, and snippets.

@ip2k
Created February 3, 2015 02:34
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 ip2k/9cc5d879d41b79f0ec3a to your computer and use it in GitHub Desktop.
Save ip2k/9cc5d879d41b79f0ec3a to your computer and use it in GitHub Desktop.
javascript show show for n ms animation
window.fn.showFor = function (jqSelector, fadeOutTimeMs, fadeInTimeMs) {
// usage: rosetta.fn.showFor('#element-id', 5000) // shows #element-id for 5 seconds, then slow fades out
if (! fadeInTimeMs) { fadeInTimeMs = 1000; }
if (! fadeOutTimeMs) { fadeOutTimeMs = 5000; }
$(jqSelector).removeClass('hidden').fadeIn(parseInt(fadeInTimeMs));
setTimeout(function () {
$(jqSelector).fadeOut(1000, function () {
$(jqSelector).addClass('hidden');
});
}, parseInt(fadeOutTimeMs));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment