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.
120 lines
3.6 KiB
120 lines
3.6 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">
|
|
<link rel="stylesheet" href="css.css">
|
|
<title>Vesmir</title>
|
|
</head>
|
|
<body>
|
|
<div id="planet">
|
|
|
|
<img class="zeme01" src="e1.jpg">
|
|
|
|
</div>
|
|
<div class="section" id="zacatek">
|
|
<div class="zarovnani">
|
|
<h1>Ahoj</h1>
|
|
</div>
|
|
|
|
</div>
|
|
<div class="section" id="cerna">
|
|
|
|
<div class="zarovnani">
|
|
<h1 style="color: aliceblue;">Ahoj</h1>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="section" id="hvezda">
|
|
|
|
<div class="zarovnani">
|
|
<h1 style="color: aliceblue;">Ahoj</h1>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
<div class="section" id="odkrytí">
|
|
<div class="zarovnani">
|
|
<h1 style="color: aliceblue;">Ahoj</h1>
|
|
</div>
|
|
|
|
</div>
|
|
<div class="section" id="rotace">
|
|
<div class="zarovnani">
|
|
<h1 style="color: aliceblue;">Ahoj</h1>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
function handler() {
|
|
let cerna = document.querySelector('#cerna');
|
|
let cerna_rect = cerna.getBoundingClientRect();
|
|
console.log(cerna_rect.top);
|
|
let value = Math.ceil(255 * (cerna_rect.top / cerna_rect.height));
|
|
if (value >= 0 && value <= 255) {
|
|
document.body.style.backgroundColor = "rgb(" + value + "," + value + "," + value + ")";
|
|
}
|
|
|
|
let hvezda = document.querySelector('#hvezda');
|
|
let hvezda_rect = hvezda.getBoundingClientRect();
|
|
let opacity =(hvezda_rect.top / hvezda_rect.height);
|
|
if (opacity >= 0 && opacity <= 1) {
|
|
console.log("Opacity: " +opacity);
|
|
document.body.style.backgroundImage = "rgb(" + opacity + "," + opacity + "," + opacity + ")";
|
|
}
|
|
|
|
let odkrytí = document.querySelector('#odkrytí');
|
|
let odkrytí_rect = odkrytí.getBoundingClientRect();
|
|
let zeme_img = document.querySelector(".zeme01");
|
|
console.log("odkrití:" + (odkrytí_rect.height - odkrytí_rect.top));
|
|
if (odkrytí_rect.height - odkrytí_rect.top > 0) {
|
|
let opacity = 1 - (odkrytí_rect.top / odkrytí_rect.height);
|
|
console.log("zjevení opacity:" + opacity);
|
|
zeme_img.style.opacity = opacity;
|
|
|
|
|
|
}
|
|
let rotace = document.querySelector('#rotace');
|
|
let rotace_rect = rotace.getBoundingClientRect();
|
|
console.log("rotace:" + (rotace_rect.height - rotace_rect.top));
|
|
if (rotace_rect.height - rotace_rect.top > 0) {
|
|
let cislo = Math.ceil(13 * (1 - (rotace_rect.top / rotace_rect.height)));
|
|
console.log("cislo:" + cislo);
|
|
if (cislo >= 1 && cislo <= 13) {
|
|
zeme_img.setAttribute("src", "e" + cislo + ".jpg");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
window.addEventListener('load', handler, false);
|
|
|
|
window.addEventListener('scroll', handler, false);
|
|
|
|
window.addEventListener('resize', handler, false);
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</body>
|
|
</html>
|