A Pen by Sanath Pathiraja on CodePen.
Created
December 8, 2017 11:14
-
-
Save sanathpathiraja/2b6d9f97bb1abd3c10b65ff701b05cc6 to your computer and use it in GitHub Desktop.
Page loader
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
<div id="overlay"></div> | |
<div id="loader"></div> <img src="https://source.unsplash.com/category/nature/500x500"> <img src="https://source.unsplash.com/category/buildings/500x500"> <img src="https://source.unsplash.com/category/food/500x500"> <img src="https://source.unsplash.com/category/people/500x500"> <img src="https://source.unsplash.com/category/technology/500x500"> <img src="https://source.unsplash.com/category/objects/500x500"> <img src="https://source.unsplash.com/category/nature/500x500"> <img src="https://source.unsplash.com/category/buildings/500x500"> <img src="https://source.unsplash.com/category/food/500x500"> <img src="https://source.unsplash.com/category/people/500x500"> <img src="https://source.unsplash.com/category/technology/500x500"> |
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 loader = document.getElementById("loader"), overlay = document.getElementById("overlay").classList; | |
overlay.add("overlay"); | |
document.onreadystatechange = function () { | |
function f_loader() { | |
loader.style.animationPlayState = "paused"; | |
loader.style.display = "none"; | |
overlay.remove("overlay"); | |
}; | |
if (document.readyState == "complete") { | |
setTimeout(f_loader, 1000); | |
}; | |
}; |
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
.overlay { | |
position: absolute; | |
top: 0; | |
left: 0; | |
width: 100%; | |
height: 100%; | |
z-index: 10; | |
background-color: rgba(0, 0, 0, 0.4); | |
/*dim the background*/ | |
} | |
#loader { | |
width: 64px; | |
height: 64px; | |
position: absolute; | |
top: 50%; | |
margin-top: -32px; | |
left: 50%; | |
margin-left: -32px; | |
border-top: 2px solid #e70814; | |
-webkit-animation: rotate 0.7s linear infinite; | |
-moz-animation: rotate 0.7s linear infinite; | |
animation: rotate 0.7s linear infinite; | |
border-radius: 50%; | |
} | |
@-webkit-keyframes rotate { | |
0% { | |
-webkit-transform: rotate(0deg); | |
} | |
100% { | |
-webkit-transform: rotate(360deg); | |
} | |
} | |
@-moz-keyframes rotate { | |
0% { | |
-moz-transform: rotate(0deg); | |
} | |
100% { | |
-moz-transform: rotate(360deg); | |
} | |
} | |
@keyframes rotate { | |
0% { | |
transform: rotate(0deg); | |
} | |
100% { | |
transform: rotate(360deg); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment