You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

124 lines
4.0 KiB

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Vesmír</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-wEmeIV1mKuiNpC+IOBjI7aAzPcEZeedi5yW5f2yOq55WWLwNGmvvx4Um1vskeMj0" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-p34f1UUtsS3wqzfto5wAAmdvj+osOnFyQFpp4Ua3gs/ZVWx6oOypYoCJhGGScy+8" crossorigin="anonymous"></script>
<style>
section{
height: 100vh;
text-align: center;
}
#hvezdy{
color: white;
}
.zeme-fixed{
width: 300px;
position: fixed;
opacity: 0;
margin-left: 50px;
margin-top: 100px;
}
.hvezdy_img{
position: fixed;
opacity: 0;
z-index: 0;
}
#zjeveni, #rotace, #end{
color: white;
position: relative;
z-index: 1;
}
</style>
</head>
<body>
<div id="stars">
<img class="hvezdy_img" src="img/stars.jpg" alt="">
</div>
<div id="zeme">
<img class="zeme-fixed" src="img/e1.jpg" alt="">
</div>
<section id="uvod">
<h2>Before the scroll,<br>
there was a void...</h2>
</section>
<section id="dark">
<h2>...then came<br>
the dark</h2>
</section>
<section id="hvezdy">
<h2>few milions years later,<br>
the stars emerged</h2>
</section>
<section id="zjeveni">
<h2>and finally,<br> the planet</h2>
</section>
<section id="rotace">
<h2>Earth formed</h2>
</section>
<section id="end">
<h2 style="padding-top: 250px;">this was the begining</h2>
</section>
<script>
function handler(){
let dark = document.querySelector('#dark');
let dark_rect = dark.getBoundingClientRect();
//console.log("dark:" + dark_rect.top);
let value = Math.ceil(255 * (dark_rect.top / dark_rect.height));
document.body.style.backgroundColor = "rgb(" + value + "," + value + "," + value + ")";
let hvezdy = document.querySelector("#hvezdy");
let hvezdy_rect = hvezdy.getBoundingClientRect();
//console.log("hvezdy: " + (hvezdy_rect.height - hvezdy_rect.top));
let hvezdy_img = document.querySelector(".hvezdy_img")
let opacity_hvezdy = 1 - (hvezdy_rect.top / hvezdy_rect.height);
hvezdy_img.style.opacity = opacity_hvezdy
let zjeveni = document.querySelector("#zjeveni");
let zjeveni_rect = zjeveni.getBoundingClientRect();
//console.log("hvezdy: " + (zjeveni_rect.height - zjeveni_rect.top));
let zeme = document.querySelector(".zeme-fixed")
let opacity = 1 - (zjeveni_rect.top / zjeveni_rect.height);
zeme.style.opacity = opacity;
let rotace = document.querySelector("#rotace")
let rotace_rect = rotace.getBoundingClientRect();
let cislo = Math.ceil(13 * (1 - (rotace_rect.top / rotace_rect.height)));
if(cislo >= 1 && cislo <=13 ){
//console.log("rotace:" + cislo)
zeme.src = ("img/e" + cislo + ".jpg");
}
let end = document.querySelector("#end");
let end_rect = end.getBoundingClientRect();
if(end_rect.height > end_rect.top ){
opacity = (end_rect.top / end_rect.height);
zeme.style.opacity = opacity;
}
}
window.addEventListener('load', handler, false);
window.addEventListener('scroll', handler, false);
window.addEventListener('resize', handler, false);
</script>
</body>
</html>