-
Notifications
You must be signed in to change notification settings - Fork 4
/
home.js
75 lines (59 loc) · 2.12 KB
/
home.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
function highlightevolve()
{
document.getElementById("evolve").style.color="#76D7C4";
}
function dehighlightevolve()
{
document.getElementById("evolve").style.color="white";
}
function openlink(url)
{
window.location.href=url;
}
function getPosition(element) {
var yPosition = 0;
while(element) {
yPosition += (element.offsetTop - element.scrollTop /*+ element.clientTop*/ ); //here offsetTop gives the distance of an element from the top of its parent
//scrolltop gives the vertical distance the element has been scrolled and clienttop is the top border width of the element
element = element.offsetParent;
}
return yPosition;
}
var poll = document.getElementById("polls");
var ann = document.getElementById("announcements");
var news = document.getElementById("news");
var contests = document.getElementById("contests");
window.onscroll = function(){
poll.style.transform="translateY(-100px)";
poll.style.opacity="0";
ann.style.transform="translateX(-100px)";
ann.style.opacity="0";
news.style.transform="translateY(-100px)";
news.style.opacity="0";
contests.style.transform="translateX(-100px)";
contests.style.opacity="0";
if(window.scrollY>=(getPosition(poll)-650))
{
poll.style.animationName="contentcomingin";
poll.style.animationDuration="0.5s";
poll.style.animationFillMode="forwards";
}
if(window.scrollY>=(getPosition(ann)-600))
{
ann.style.animationName="anncontestcontentcomingin";
ann.style.animationDuration="0.5s";
ann.style.animationFillMode="forwards";
}
if(window.scrollY>=(getPosition(news)-600))
{
news.style.animationName="contentcomingin";
news.style.animationDuration="0.5s";
news.style.animationFillMode="forwards";
}
if(window.scrollY>=(getPosition(contests)-600))
{
contests.style.animationName="anncontestcontentcomingin";
contests.style.animationDuration="0.5s";
contests.style.animationFillMode="forwards";
}
}