Skip to content

@TiuTalk /gist:3624019
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
var blink = {
delay: function() {
return Math.random() * 8000 + 2000;
},
duration: function() {
return 100 + Math.floor(Math.random() * 100);
},
blinkAgain: function() {
return (Math.random() < .2);
},
betweenBliks: function() {
return blink.duration() / 2;
}
};
$.fn.blink = function(continueBlinking) {
var $element = $(this);
// Star the blink
$element.addClass('blink');
// Finish the blink
setTimeout(function() {
$element.removeClass('blink');
// Change of blinking again
if (blink.blinkAgain()) {
setTimeout(function() {
$element.blink(false);
}, blink.betweenBliks());
}
}, blink.duration());
// Continue blinking?
if (continueBlinking) {
setTimeout(function() {
$element.blink(true);
}, blink.delay());
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.