-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
145 lines (127 loc) · 3.87 KB
/
index.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
//////////////////////////////////////
//////////////////////////////////////
//////////////////////////////////////
////////// SCROLL TO TOP /////////////
//////////////////////////////////////
//////////////////////////////////////
//////////////////////////////////////
const backToTopButton = document.getElementById("back_to_top");
window.addEventListener("scroll", function () {
if (window.scrollY > 100) {
backToTopButton.classList.add("show");
} else {
backToTopButton.classList.remove("show");
}
});
backToTopButton.addEventListener("click", function () {
document.getElementById("spacing1").scrollIntoView({
behavior: "smooth",
});
});
//////////////////////////////////////
//////////////////////////////////////
//////////////////////////////////////
/////////// SET SPACING //////////////
//////////////////////////////////////
//////////////////////////////////////
//////////////////////////////////////
const spacing1 = document.getElementById("spacing1");
navbar.setAttribute(
"style",
"height: " +
(document.getElementById("navbar_inner").clientHeight + 2) +
"px;"
);
spacing1.setAttribute(
"style",
"height: " + document.getElementById("navbar").clientHeight + "px;"
);
addEventListener("resize", () => {
navbar.setAttribute(
"style",
"height: " +
(document.getElementById("navbar_inner").clientHeight + 2) +
"px;"
);
spacing1.setAttribute("style", "height: " + navbar.clientHeight + "px;");
});
//////////////////////////////////////
//////////////////////////////////////
//////////////////////////////////////
//////////////////////////////////////
//////////////////////////////////////
////////////// LOADING ///////////////
//////////////////////////////////////
//////////////////////////////////////
//////////////////////////////////////
//////////////////////////////////////
//////////////////////////////////////
//////////////////////////////////////
//////////////////////////////////////
function startLoader() {
let counterElement = document.querySelector("#count2");
let loadingElement = document.querySelector("#count1");
let currentValue = 0;
function updateCounter() {
if (currentValue === 100) {
gsap.to(".counter", 0.25, {
opacity: 0,
});
gsap.to(".bar", 1.5, {
height: 0,
stagger: {
amount: 0.5,
},
ease: "power4.inOut",
});
gsap.to(".counter", 0.25, {
delay: 1,
height: 0,
});
loadingElement.innerHTML = ""
return;
}
currentValue += Math.floor(Math.random() * 20) + 1;
if (currentValue > 100) {
currentValue = 100;
}
counterElement.textContent = currentValue;
let delay = Math.floor(Math.random() * 200) + 120;
setTimeout(updateCounter, delay);
}
updateCounter();
}
startLoader();
//////////////////////////////////////
//////////////////////////////////////
//////////////////////////////////////
////////// SCROLL ON LOAD /////////////
//////////////////////////////////////
//////////////////////////////////////
//////////////////////////////////////
window.addEventListener("load", function () {
document.getElementById("spacing1").scrollIntoView({
behavior: "smooth",
});
});
//////////////////////////////////////
//////////////////////////////////////
//////////////////////////////////////
/////// SCROLL TO PROJECTS ///////////
//////////////////////////////////////
//////////////////////////////////////
//////////////////////////////////////
document
.getElementById("projects_button_tag_2")
.addEventListener("click", function () {
document.getElementById("projects_title").scrollIntoView({
behavior: "smooth",
});
});
document
.getElementById("projects_nav")
.addEventListener("click", function () {
document.getElementById("projects_title").scrollIntoView({
behavior: "smooth",
});
});