photo-go/index.html

96 lines
2.4 KiB
HTML
Raw Normal View History

2021-04-11 13:04:56 +00:00
<!DOCTYPE html>
<html>
<head>
<title>Photos</title>
<style>
html, body {
margin: 0;
padding: 0;
height: 100vh;
width: 100vw;
overflow: hidden;
}
2021-04-11 13:04:56 +00:00
.image {
position: absolute;
top: 0;
left: 0;
height: 100vh;
width: 100vw;
display: block;
opacity: 0;
text-align: center;
2021-04-11 13:04:56 +00:00
-webkit-transition: opacity 3s ease-in-out;
-moz-transition: opacity 3s ease-in-out;
-o-transition: opacity 3s ease-in-out;
transition: opacity 3s ease-in-out;
}
.image .bg {
display: block;
position: absolute;
top: 0;
left: 0;
height: 100vh;
width: 100vw;
z-index: -1;
background-size: cover;
background-repeat: no-repeat;
background-position: center center;
filter: blur(30px);
-webkit-filter: blur(30px);
-moz-filter: blur(30px);
-o-filter: blur(30px);
-ms-filter: blur(30px);
}
2021-04-11 13:04:56 +00:00
.image.active {
opacity: 1;
}
.image img {
max-height: 100vh;
max-width: 100vw;
position: relative;
top: 50%;
transform: translateY(-50%);
}
2021-04-11 13:04:56 +00:00
</style>
</head>
<body>
<div class="image active">
<div class="bg"></div>
<img />
</div>
<div class="image">
<div class="bg"></div>
<img />
</div>
2021-04-11 13:04:56 +00:00
<script type="text/javascript">
let crop = window.location.search.includes("crop");
2021-04-11 13:04:56 +00:00
function process() {
const width = document.documentElement.clientWidth;
const height = document.documentElement.clientHeight;
const timestamp = (new Date()).getTime();
let nextElement = document.querySelector('.image:not(.active)');
let im = new Image();
im.src = `/image/?width=${width}&height=${height}&ts=${timestamp}&crop=${crop ? 'true' : 'false'}`;
if (crop) {
im.style.width = "100vw";
im.style.height = "100vh";
}
2021-04-11 13:04:56 +00:00
im.onload = function() {
nextElement.querySelector('.bg').style.backgroundImage = `url('${im.src}')`;
nextElement.replaceChild(im, nextElement.querySelector('img'));
2021-04-11 13:04:56 +00:00
[...document.querySelectorAll('.image')].forEach(el => el.classList.toggle('active'));
setTimeout(process, 5000);
};
}
process();
</script>
</body>
</html>