Skip to content

Instantly share code, notes, and snippets.

@damirm
Last active September 16, 2016 07:56
Show Gist options
  • Save damirm/9ab8119c46cf17f7bed755f6a76c0942 to your computer and use it in GitHub Desktop.
Save damirm/9ab8119c46cf17f7bed755f6a76c0942 to your computer and use it in GitHub Desktop.
function shrug(el, speed, i) {
var enabled = true;
var shurgs = [
"¯\\_(ツ)_/¯",
"_/¯(ツ)_/¯",
"_/¯(ツ)¯\\_",
"¯\\_(ツ)¯\\_"
];
if (typeof i === 'undefined' || i >= shurgs.length) {
i = 0;
}
el.innerText = shurgs[i];
var timeout = setTimeout(function () {
enabled && shrug(el, speed, ++i);
}, speed);
return function () {
clearTimeout(timeout);
enabled = false;
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment