-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
194 lines (182 loc) · 4.77 KB
/
app.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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
document.addEventListener("DOMContentLoaded", function () {
// Add 'overflow-hidden' class to the body
document.body.classList.add("overflow-hidden");
document.body.classList.add("h-100vh");
// Remove 'overflow-hidden' class after 3 seconds
setTimeout(function () {
document.body.classList.remove("overflow-hidden");
document.body.classList.remove("h-100vh");
}, 3000);
});
//loader Animation
const progressText = document.querySelector(".progress-text");
const progressFill = document.querySelector(".progress-fill");
let count = { value: 0 };
anime({
targets: count,
value: 100, // Final value to count up to
round: 1, // Round to 1 decimal place
easing: "easeInOutQuad", // Use linear easing
duration: 3000, // Animation duration in milliseconds
endDelay: 300,
update: function () {
// Update the counter element's text content
progressText.textContent = count.value + "%";
if (count.value == 100) {
// progressFill.style.backgroundColor = "rgb(64, 241, 39)";
// progressText.style.color = "rgb(64 , 241 , 40)";
anime({
targets: ".loader",
// scale: 0,
translateY: -1000,
opacity: 0.7,
easing: "easeInOutQuad",
height: "0px",
});
}
},
});
//set body width to 100%
anime({
targets: "body",
height: "100vh",
overflow: " ",
easing: "easeInOutQuad",
duration: 3000,
});
anime({
targets: ".progress-fill",
width: "100%",
easing: "easeInOutQuad",
duration: 3000,
});
anime({
targets: ".loader",
opacity: 0,
delay: 3200,
zIndex: -1,
});
//grid Animation
const grid = document.querySelector(".grid");
let index = 0;
let gridWidth = 22;
let gridHeight = 15;
function createGrid() {
grid.style.gridTemplateColumns = `repeat(${gridWidth}, 1fr)`;
for (let i = 0; i < gridWidth; i++) {
for (let j = 0; j < gridHeight; j++) {
let gridBox = document.createElement("div");
gridBox.setAttribute("data-index", index);
gridBox.setAttribute("onclick", "handleDotClick(event)");
gridBox.setAttribute("key", `${i}-${j}`);
gridBox.classList.add("gridBox");
let dotPoint = document.createElement("div");
dotPoint.setAttribute("data-index", index);
dotPoint.classList.add("dot-point");
gridBox.append(dotPoint);
grid.append(gridBox);
index++;
// console.log("Grid Created!");
}
}
}
createGrid();
const handleDotClick = (e) => {
count = count - 3000;
console.log(e.target.dataset.index);
anime({
targets: ".dot-point",
scale: [
{ value: 1.35, easing: "easeOutSine", duration: 250 },
{ value: 1, easing: "easeInOutQuad", duration: 500 },
],
translateY: [
{ value: -15, easing: "easeOutSine", duration: 250 },
{ value: 0, easing: "easeInOutQuad", duration: 500 },
],
opacity: [
{ value: 1, easing: "easeOutSine", duration: 250 },
{ value: 0.5, easing: "easeInOutQuad", duration: 500 },
],
delay: anime.stagger(100, {
grid: [gridWidth, gridHeight],
from: e.target.dataset.index,
}),
});
};
setInterval(() => {
anime({
targets: ".dot-point",
scale: [
{ value: 1.35, easing: "easeOutSine", duration: 250 },
{ value: 1, easing: "easeInOutQuad", duration: 500 },
],
translateY: [
{ value: -15, easing: "easeOutSine", duration: 250 },
{ value: 0, easing: "easeInOutQuad", duration: 500 },
],
opacity: [
{ value: 1, easing: "easeOutSine", duration: 250 },
{ value: 0.5, easing: "easeInOutQuad", duration: 500 },
],
delay: anime.stagger(100, {
grid: [gridWidth, gridHeight],
from: getRandomNumber(),
}),
});
}, 8000);
function getRandomNumber() {
var randomNumber = Math.floor(Math.random() * (320 - 1 + 1)) + 1;
console.log(randomNumber);
return randomNumber;
}
setInterval(getRandomNumber, 3000);
//square animation
anime({
target: ".square",
translateY: 50,
loop: true,
duration: 1000,
delay: 5000,
opacity: [
{ value: 1, easing: "easeOutSine", duration: 250 },
{ value: 0.5, easing: "easeInOutQuad", duration: 500 },
],
easing: "easeOutSine",
});
let squares = document.querySelector(".squares");
function createSquares() {
for (let a = 0; a < 10; a++) {
for (let b = 0; b < 5; b++) {
let square = document.createElement("div");
square.classList.add("square");
squares.append(square);
}
}
}
createSquares();
anime({
targets: ".squares",
translateY: 50,
direction: "alternate",
opacity: [0.7, 1],
loop: true,
duration: 5000,
easing: "easeInOutCubic",
});
anime({
targets: ".rect-rotate",
ratate: 360,
loop: true,
easing: "easeInOutQuad",
duration: 3000,
loop: true,
});
anime({
targets: ".rect-rotate",
rotate: 360,
duration: 4000,
easing: "linear",
loop: true,
direction: "normal",
});