Created
November 12, 2016 03:07
-
-
Save Jae-kwang/da414a7cc7c1990a5cdf764d56212989 to your computer and use it in GitHub Desktop.
very simple script loding bar
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
#scriptProgressBar { | |
position: fixed; | |
width: 0; | |
top: 0; | |
left: 0; | |
z-index: 1031; | |
height: 3px; | |
background-color: #ffffff; | |
-webkit-box-shadow: 0 0 10px #29d; | |
box-shadow: 0 0 10px #29d; | |
-webkit-transition: width 1s ease-in-out; | |
transition: width 1s ease-in-out; | |
} |
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
<div id="scriptProgressBar"></div> |
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
<script type="text/javascript"> | |
(function() { | |
var scriptProgressBar = document.getElementById('scriptProgressBar'); | |
var setProgress = function(number) { | |
scriptProgressBar.style.width = number + '%'; | |
if (number == 100) { | |
setTimeout(function() { | |
scriptProgressBar.parentNode.removeChild(scriptProgressBar); | |
}, 1000); | |
} | |
}; | |
setProgress(10); | |
document.onreadystatechange = function () { | |
if (document.readyState === "interactive") setProgress(40); | |
if (document.readyState === "complete") setProgress(80); | |
}; | |
window.onload = function() { | |
setProgress(100); | |
}; | |
})(); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment