Created
August 24, 2012 13:46
-
-
Save adesignl/3450708 to your computer and use it in GitHub Desktop.
A Fading Loop Juery Plugin By: Justin Talant
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
// Fading Loop Through Items specified in a container | |
// -------------------------------------------------- | |
// Usage | |
// $('#tml-container > p').fadeLoop({ | |
// fadeIn: 6000, | |
// stay: 3000, | |
// fadeOut: 6000 | |
// }); | |
(function($) { | |
var default_config = { | |
fadeIn: 3000, | |
stay: 3000, | |
fadeOut: 3000 | |
}; | |
function fade(index, $elements, config) { | |
$elements.eq(index) | |
.fadeIn(config.fadeIn) | |
.delay(config.stay) | |
.fadeOut(config.fadeOut, function() { | |
fade((index + 1) % $elements.length, $elements, config); | |
}); | |
} | |
$.fn.fadeLoop = function(config) { | |
fade(0, this, $.extend({}, default_config, config)); | |
return this; | |
}; | |
}(jQuery)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment