Last active
December 20, 2015 07:28
-
-
Save shrunyan/6093109 to your computer and use it in GitHub Desktop.
Page loader; CSS animation that is deactivated by javascript after page is loaded. Source: medium.com
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
<!DOCTYPE HTML> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | |
<title>Loading Bar Test</title> | |
<style> | |
/** | |
* Animations | |
* | |
* Borrowed from Medium.com source | |
*/ | |
@-webkit-keyframes shift-rightwards { | |
0% { | |
-webkit-transform:translateX(-100%); | |
-moz-transform:translateX(-100%); | |
-o-transform:translateX(-100%); | |
transform:translateX(-100%) | |
} | |
40% { | |
-webkit-transform:translateX(0%); | |
-moz-transform:translateX(0%); | |
-o-transform:translateX(0%); | |
transform:translateX(0%) | |
} | |
60% { | |
-webkit-transform:translateX(0%); | |
-moz-transform:translateX(0%); | |
-o-transform:translateX(0%); | |
transform:translateX(0%) | |
} | |
100% { | |
-webkit-transform:translateX(100%); | |
-moz-transform:translateX(100%); | |
-o-transform:translateX(100%); | |
transform:translateX(100%) | |
} | |
} | |
@-moz-keyframes shift-rightwards { | |
0% { | |
-webkit-transform:translateX(-100%); | |
-moz-transform:translateX(-100%); | |
-o-transform:translateX(-100%); | |
transform:translateX(-100%) | |
} | |
40% { | |
-webkit-transform:translateX(0%); | |
-moz-transform:translateX(0%); | |
-o-transform:translateX(0%); | |
transform:translateX(0%) | |
} | |
60% { | |
-webkit-transform:translateX(0%); | |
-moz-transform:translateX(0%); | |
-o-transform:translateX(0%); | |
transform:translateX(0%) | |
} | |
100% { | |
-webkit-transform:translateX(100%); | |
-moz-transform:translateX(100%); | |
-o-transform:translateX(100%); | |
transform:translateX(100%) | |
} | |
} | |
@-o-keyframes shift-rightwards { | |
0% { | |
-webkit-transform:translateX(-100%); | |
-moz-transform:translateX(-100%); | |
-o-transform:translateX(-100%); | |
transform:translateX(-100%) | |
} | |
40% { | |
-webkit-transform:translateX(0%); | |
-moz-transform:translateX(0%); | |
-o-transform:translateX(0%); | |
transform:translateX(0%) | |
} | |
60% { | |
-webkit-transform:translateX(0%); | |
-moz-transform:translateX(0%); | |
-o-transform:translateX(0%); | |
transform:translateX(0%) | |
} | |
100% { | |
-webkit-transform:translateX(100%); | |
-moz-transform:translateX(100%); | |
-o-transform:translateX(100%); | |
transform:translateX(100%) | |
} | |
} | |
@keyframes shift-rightwards { | |
0% { | |
-webkit-transform:translateX(-100%); | |
-moz-transform:translateX(-100%); | |
-o-transform:translateX(-100%); | |
transform:translateX(-100%) | |
} | |
40% { | |
-webkit-transform:translateX(0%); | |
-moz-transform:translateX(0%); | |
-o-transform:translateX(0%); | |
transform:translateX(0%) | |
} | |
60% { | |
-webkit-transform:translateX(0%); | |
-moz-transform:translateX(0%); | |
-o-transform:translateX(0%); | |
transform:translateX(0%) | |
} | |
100% { | |
-webkit-transform:translateX(100%); | |
-moz-transform:translateX(100%); | |
-o-transform:translateX(100%); | |
transform:translateX(100%) | |
} | |
} | |
.loading-bar { | |
position:fixed; | |
display:none; | |
top:0; | |
left:0; | |
right:0; | |
z-index:800; | |
/* Adjust these to get your look and feel*/ | |
height: 20px; | |
background:#60d778; | |
-webkit-transform:translateX(100%); | |
-moz-transform:translateX(100%); | |
-o-transform:translateX(100%); | |
transform:translateX(100%) | |
} | |
.app-loading .loading-bar { | |
display:block; | |
-webkit-animation:shift-rightwards 1s ease-in-out infinite; | |
-moz-animation:shift-rightwards 1s ease-in-out infinite; | |
-ms-animation:shift-rightwards 1s ease-in-out infinite; | |
-o-animation:shift-rightwards 1s ease-in-out infinite; | |
animation:shift-rightwards 1s ease-in-out infinite; | |
-webkit-animation-delay:.4s; | |
-moz-animation-delay:.4s; | |
-o-animation-delay:.4s; | |
animation-delay:.4s | |
} | |
</style> | |
</head> | |
<body> | |
<div id="app" class="app-loading"> | |
<div class="loading-bar"></div> | |
<img src="http://marriedwithdebt.com/wp-content/uploads/2012/03/Velociraptor_1.jpg" alt=""> | |
</div> | |
</body> | |
<script type="text/javascript"> | |
/** | |
* Turn off loader | |
*/ | |
window.onload = function(){ | |
document.getElementById('app').className = ''; | |
}; | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment