Created
February 3, 2015 02:34
-
-
Save ip2k/9cc5d879d41b79f0ec3a to your computer and use it in GitHub Desktop.
javascript show show for n ms animation
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
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