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.
82 lines
2.8 KiB
82 lines
2.8 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/main.css">
|
|
<title>Document</title>
|
|
</head>
|
|
<body>
|
|
<section id="earth">
|
|
<img class="earth-fixed" src="img/e1.jpg" alt="">
|
|
There was Earth
|
|
</section>
|
|
<section id="uvod">
|
|
Before Void
|
|
</section>
|
|
<section id="dark">
|
|
There was Dark
|
|
</section>
|
|
<section id="after">
|
|
<img class="stars" src="img/stars.jpg" alt="">
|
|
After Dark
|
|
</section>
|
|
<section id="zjeveni">
|
|
THERE WAS EARTH
|
|
</section>
|
|
<section id="rotace">
|
|
<p class="evolvedtext">EVOLVED INTO WHAT WE SEE TODAY</p>
|
|
</section>
|
|
|
|
|
|
<script>
|
|
function handler() {
|
|
let dark = document.querySelector('#dark');
|
|
let dark_rect = dark.getBoundingClientRect();
|
|
console.log(dark_rect.top);
|
|
let value = Math.ceil(255 * (dark_rect.top / dark_rect.height));
|
|
if (value >= 0 && value <= 255 ){
|
|
document.body.style.backgroundColor = "rgb(" + value + "," + value + "," + value + ")";
|
|
}
|
|
// document.body.style.backgroundColor = "rgb(" + value + "," + value + "," + value + ")";
|
|
|
|
|
|
let after = document.querySelector("#after");
|
|
let after_rect = after.getBoundingClientRect();
|
|
let after_img = document.querySelector(".stars")
|
|
if (after_rect.height - after_rect.top > 0){
|
|
let opacity = (after_rect.top / after_rect.height);
|
|
}
|
|
|
|
|
|
|
|
let zjeveni = document.querySelector('#zjeveni');
|
|
let zjeveni_rect = zjeveni.getBoundingClientRect();
|
|
let zeme_img = document.querySelector(".earth-fixed");
|
|
let evolvedtext_appear = document.querySelector(".evolvedtext")
|
|
if (zjeveni_rect.height - zjeveni_rect.top > 0){
|
|
let opacity = 1 -(zjeveni_rect.top / zjeveni_rect.height);
|
|
zeme_img.style.opacity = opacity;
|
|
after_img.style.opacity = opacity;
|
|
evolvedtext_appear.style.opacity = opacity;
|
|
}
|
|
|
|
let rotace = document.querySelector('#rotace');
|
|
let rotace_rect = rotace.getBoundingClientRect();
|
|
if (rotace_rect.height - rotace_rect.top > 0){
|
|
let cislo = Math.ceil(13* (1 - (rotace_rect.top / rotace_rect.height)));
|
|
if (cislo >= 1 && cislo <= 13 ){
|
|
zeme_img.setAttribute("src", "img/e" + cislo + ".jpg")
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
window.addEventListener('load', handler, false)
|
|
window.addEventListener('scroll', handler, false)
|
|
window.addEventListener('resize', handler, false)
|
|
</script>
|
|
</body>
|
|
</html>
|