Last active
December 7, 2023 12:19
-
-
Save nkbt/6549487 to your computer and use it in GitHub Desktop.
Old fashioned loader
This file contains hidden or 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 loading = "\\|/—", | |
| tick = 0, | |
| loadingElement = document.createElement('div'); | |
| loadingElement.id = 'loading'; | |
| loadingElement.style.fontFamily = 'Consolas, "Liberation Mono", Courier, monospace'; | |
| document.body.innerHTML = ''; | |
| document.body.appendChild(loadingElement); | |
| (function animate() { | |
| tick = (tick + 1) % loading.length; | |
| var $element = document.querySelector('#loading'); | |
| if ($element) { | |
| $element.innerHTML = ["Loading", loading[tick]].join(' ... '); | |
| setTimeout(animate, 100); | |
| } | |
| })(); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See it in action: http://jsfiddle.net/nkbt/1Ldm1bqt/embedded/result/