Skip to content

Instantly share code, notes, and snippets.

@evaisse
Created April 6, 2010 19:02
Show Gist options
  • Save evaisse/357955 to your computer and use it in GitHub Desktop.
Save evaisse/357955 to your computer and use it in GitHub Desktop.
(function($){
$.fn.textspinner = function(options) {
var defaults = {
fadeInTime: 200,
fadeOutTime: 200,
showDelay: 200
};
var content = new Array();
var options = $.extend(defaults, options);
var o, container;
// private function for debugging
function debug(obj) {
if (window.console && window.console.log)
window.console.log(obj);
};
function changeContent() {
if( $(o).html().length > 3 )
$(o).html( '.' ) ;
else
$(o).html( $(o).html() + '.' ) ;
animate();
};
function animate() {
if( $.fn.spin.spinning == false ) {
return false;
}
//debug( $(o).html() )
$(o).fadeIn()
.animate({opacity: 1.0}, {
duration: options.fadeInTime
})
.delay( options.showDelay )
.animate({opacity: 0.6}, {
duration: options.fadeOutTime,
complete: changeContent
})
};
return this.each(function() {
o = $(this);
$.fn.spin.spinning = true;
animate();
});
}
})(jQuery);
$('#spinner').textspinner();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment