forked from rudrathegreat/astral-website
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapply_section_grid_effect.js
More file actions
39 lines (26 loc) · 1016 Bytes
/
apply_section_grid_effect.js
File metadata and controls
39 lines (26 loc) · 1016 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
38
39
let columns_2 = 0,
rows_2 = 0;
const wrapper_2 = document.querySelector(".apply .effect-container");
const wrapper_grid_2 = document.querySelector('.apply .effect-container .grid-effect')
const createTile_2 = index_2 => {
const tile_2 = document.createElement("div");
tile_2.classList.add("tile");
tile_2.style.opacity = 0.3;
return tile_2;
}
const createTiles_2 = quantity_2 => {
Array.from(Array(quantity_2)).map((tile_2, index_2) => {
wrapper_grid_2.appendChild(createTile_2(index_2));
});
}
const createGrid_2 = () => {
wrapper_grid_2.innerHTML = "";
const size = wrapper_2.clientWidth > 800 ? 100 : 100;
columns_2 = Math.floor(wrapper_2.clientWidth / size);
rows_2 = Math.floor(wrapper_2.clientHeight / size);
wrapper_grid_2.style.setProperty("--columns", columns_2);
wrapper_grid_2.style.setProperty("--rows", rows_2);
createTiles_2(columns_2 * rows_2);
}
createGrid_2();
window.onresize = () => createGrid_2();