Skip to content

Instantly share code, notes, and snippets.

@scriptum
Created February 27, 2017 08:51
Show Gist options
  • Select an option

  • Save scriptum/b6eb3f6fa19cdb15d9dfe0e07637d19c to your computer and use it in GitHub Desktop.

Select an option

Save scriptum/b6eb3f6fa19cdb15d9dfe0e07637d19c to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<style type="text/css">
* {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
background: black;
}
div {
background-size: cover;
background-position: center;
position: absolute;
opacity: 0;
}
@-webkit-keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
.fade {
-webkit-animation: fadeIn ease-in 1;
-webkit-animation-fill-mode:forwards;
-webkit-animation-duration:2s;
animation: fadeIn ease-in 1;
animation-fill-mode:forwards;
animation-duration:2s;
}
</style>
<script type="text/javascript">
var b;
var d1, d2;
/* find /usr/share/backgrounds/ -type f | sed "s/^.*$/'\0',/" */
var img = [$IMG];
ind = img.length;
function shuffle(o)
{
for(var j, x, i = o.length; i; j = Math.floor(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
return o;
}
function rndImg()
{
if(ind >= img.length)
{
ind = 0;
var last = img[img.length];
do
{
shuffle(img);
} while(last == img[0]);
}
return img[ind++];
}
function tick()
{
b.removeChild(d1);
d1 = d2;
d2 = document.createElement("div");
b.appendChild(d2);
d2.style.backgroundImage = "url('"+rndImg()+"')";
d2.className = "fade";
}
window.onload = function()
{
b = document.body;
d1 = document.createElement("div");
b.appendChild(d1);
d2 = document.createElement("div");
b.appendChild(d2);
tick();
setInterval(tick, 3000)
}
</script>
</head>
<body>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment