Skip to content

Instantly share code, notes, and snippets.

@luckylooke
Forked from jiripudil/spinner.html
Last active April 5, 2017 16:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luckylooke/4173b00e73309d6f2153f77cc542e17b to your computer and use it in GitHub Desktop.
Save luckylooke/4173b00e73309d6f2153f77cc542e17b to your computer and use it in GitHub Desktop.
Pure JavaScript spinner
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Pure JS spinner</title>
<style>
#spinner { font-size: 6em; }
</style>
</head>
<body>
<div id="spinner"></div>
<script>
var chars = '┤┘┴└├┌┬┐'.split('');
var chars = '⣾⣽⣻⢿⡿⣟⣯⣷'.split('');
var chars = '⠁⠂⠄⡀⢀⠠⠐⠈'.split('');
var chars = '▖▘▝▗'.split('');
function spin() {
var char = chars.shift();
document.querySelector('#spinner').innerHTML = char;
chars.push(char);
setTimeout(spin, 150);
}
spin();
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment