Created
November 8, 2013 18:12
-
-
Save entomb/7375162 to your computer and use it in GitHub Desktop.
Cute loading icon for the title bar.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var cuteLoading = (function(){ | |
//var sequence = "◑ ◓ ◐ ◒"; | |
//var sequence = "◢ ◣ ◤ ◥"; | |
//var sequence = "▁ ▂ ▃ ▄ ▅ ▆ ▇ █ ▇ ▆ ▅ ▄ ▃ ▂ ▁"; | |
var sequence = "✴ ✷ ✶ ✸ ✹ ✺ ❁ ❂ ❁ ✺ ✹ ✶ ✷ ✴"; | |
var cacheTitle; | |
var _timeout; | |
function startLoading(){ | |
if(_timeout) return this; | |
cacheTitle = window.document.title; | |
var index = 0; | |
var frames = sequence.split(" "); | |
_timeout = setInterval(function(){ | |
index++; | |
if(index==frames.length){ | |
index = 0; | |
} | |
window.document.title = frames[index] + " " + cacheTitle; | |
},100); | |
return this; | |
} | |
function stopLoading(){ | |
if(!_timeout) return this; | |
clearTimeout(_timeout); | |
_timeout = null; | |
window.document.title = cacheTitle; | |
return this; | |
} | |
function setSequence(i){ | |
sequence = i; | |
return this; | |
} | |
return { | |
sequence: setSequence, | |
start:startLoading, | |
stop:stopLoading, | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment