Skip to content

Instantly share code, notes, and snippets.

@klarstil
Created July 10, 2013 10:06
Show Gist options
  • Save klarstil/5965132 to your computer and use it in GitHub Desktop.
Save klarstil/5965132 to your computer and use it in GitHub Desktop.
Simple dot animation
;(function($) {
var flashingDots = function(el) {
var dots = el.data('default-value') || el.html(),
i = 0;
if(!el.data('default-value')) {
el.data('default-value', el.html());
}
return {
el: el,
interval: setInterval(function() {
el.html(dots.substring(0, i % 4));
i += 1;
}, 200)
}
};
var flashing = flashingDots($('.flashing-dots'));
window.setTimeout(function() {
flashing.el.html('!');
clearInterval(flashing.interval);
}, 2000);
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment