Skip to content

Instantly share code, notes, and snippets.

@mimshwright
Created April 10, 2014 00:06
Show Gist options
  • Save mimshwright/10331884 to your computer and use it in GitHub Desktop.
Save mimshwright/10331884 to your computer and use it in GitHub Desktop.
Draw a spinner in your console.
var timer;
function showSpinner() {
var i = 0;
var css = "font-size: 32px; color: red;";
clearInterval(timer);
timer = setInterval(
function () {
console.clear();
// console.log(timer);
i++;
switch(i%4) {
case 0: console.log("%c |", css); break;
case 1: console.log("%c /", css); break;
case 2: console.log("%c –", css); break;
case 3: console.log("%c \\", css); break;
default: break;
}
}
, 50);
}
function stopSpinner() {
clearInterval(timer);
}
showSpinner();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment