-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
155 lines (116 loc) · 4.26 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
window.onunload = function () {
window.scrollTo(0, 0);
}
window.onbeforeunload = function () {
document.getElementById('screen-darkener').style.opacity = '1';
document.getElementById('screen-darkener').style.visibility = 'visible';
}
var prevScrollpos = window.pageYOffset;
window.onscroll = function() {
var currentScrollPos = window.pageYOffset;
var quarterscreenheight = (screen.height)/4
var halfscreenheight = (screen.height)/2
if (prevScrollpos > currentScrollPos) {
document.getElementById("topNav").style.top = "0";
} else if (prevScrollpos <= currentScrollPos && currentScrollPos > quarterscreenheight) {
document.getElementById("topNav").style.top = "-20vh";
}
prevScrollpos = currentScrollPos;
prevScrollpos = currentScrollPos;
if (currentScrollPos <= halfscreenheight) {
document.getElementById("topNav").style.backgroundColor = "rgba(0,0,0,0)";
} else {
document.getElementById("topNav").style.backgroundColor = "rgba(0,0,0,1)";
}
}
function reveal() {
var reveals = document.querySelectorAll(".phase-cover-text");
var reveals2 = document.querySelectorAll(".timeline-text");
var reveals3 = document.querySelectorAll(".mars-info-table-row");
var reveals4 = document.querySelectorAll(".mars-counter-number");
var reveals5 = document.querySelectorAll(".location-row");
var reveals6 = document.querySelectorAll(".location-text");
var reveals7 = document.querySelectorAll(".component-reveals");
var reveals8 = document.querySelectorAll(".mars-counter-text");
for (var i = 0; i < reveals.length; i++) {
var windowHeight = window.innerHeight;
var elementTop = reveals[i].getBoundingClientRect().top;
var elementVisible = 0;
if (elementTop < windowHeight - elementVisible) {
reveals[i].classList.add("active");
} else {
reveals[i].classList.remove("active");
}
}
for (var i = 0; i < reveals2.length; i++) {
var windowHeight = window.innerHeight;
var elementTop = reveals2[i].getBoundingClientRect().top;
var elementVisible = 150;
if (elementTop < windowHeight - elementVisible) {
reveals2[i].classList.add("active2");
} else {
reveals2[i].classList.remove("active2");
}
}
for (var i = 0; i < reveals3.length; i++) {
var windowHeight = window.innerHeight;
var elementTop = reveals3[i].getBoundingClientRect().top;
var elementVisible = 0;
if (elementTop < windowHeight - elementVisible) {
reveals3[i].classList.add("active3");
} else {
reveals3[i].classList.remove("active3");
}
}
for (var i = 0; i < reveals4.length; i++) {
var windowHeight = window.innerHeight;
var elementTop = reveals4[i].getBoundingClientRect().top;
var elementVisible = 0;
if (elementTop < windowHeight - elementVisible) {
reveals4[i].classList.add("active4");
} else {
reveals4[i].classList.remove("active4");
}
}
for (var i = 0; i < reveals5.length; i++) {
var windowHeight = window.innerHeight;
var elementTop = reveals5[i].getBoundingClientRect().top;
var elementVisible = 0;
if (elementTop < windowHeight - elementVisible) {
reveals5[i].classList.add("active5");
} else {
reveals5[i].classList.remove("active5");
}
}
for (var i = 0; i < reveals6.length; i++) {
var windowHeight = window.innerHeight;
var elementTop = reveals6[i].getBoundingClientRect().top;
var elementVisible = 0;
if (elementTop < windowHeight - elementVisible) {
reveals6[i].classList.add("active6");
} else {
reveals6[i].classList.remove("active6");
}
}
for (var i = 0; i < reveals7.length; i++) {
var windowHeight = window.innerHeight;
var elementTop = reveals7[i].getBoundingClientRect().top;
var elementVisible = 100;
if (elementTop < windowHeight - elementVisible) {
reveals7[i].classList.add("active7");
} else {
reveals7[i].classList.remove("active7");
}
}
for (var i = 0; i < reveals8.length; i++) {
var windowHeight = window.innerHeight;
var elementTop = reveals8[i].getBoundingClientRect().top;
var elementVisible = 0;
if (elementTop < windowHeight - elementVisible) {
reveals8[i].classList.add("active8");
} else {
reveals8[i].classList.remove("active8");
}
}
}
window.addEventListener("scroll", reveal);