-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.js
More file actions
37 lines (31 loc) · 981 Bytes
/
app.js
File metadata and controls
37 lines (31 loc) · 981 Bytes
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
const flagEl = document.querySelector(".flag");
const rows = 50;
const columns = 30;
const rainbowColors = [
"#e40303",
"#ff8c00",
"#ffed00",
"#008026",
"#004dff",
"#750787",
];
const generateUnit = (columnNum, rowNum) => {
const flagUnit = document.createElement("div");
flagUnit.classList.add("flag-unit");
flagUnit.style.setProperty("animation-delay", `${columnNum * 10}ms`);
flagUnit.style.setProperty("--displacement", `${columnNum / 2.5}`);
const colorIndex = Math.floor(rowNum / (rows / rainbowColors.length));
flagUnit.style.backgroundColor = rainbowColors[colorIndex];
const column = document.getElementById(`column-${columnNum}`);
column.appendChild(flagUnit);
};
for (let i = 0; i < columns; i++) {
const column = document.createElement("div");
column.classList.add("column");
column.id = `column-${i}`;
column.style.width = "10px";
flagEl.appendChild(column);
for (let j = 0; j < rows; j++) {
generateUnit(i, j);
}
}