-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
30 lines (28 loc) · 775 Bytes
/
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
let paths = [];
let drawFPS = 30;
let distancePerPoint = 0.5;
let borderColor = "#1DB954";
let length = 1;
let pathIndex = 0;
let timer = setInterval(animation, 1000 / drawFPS);
document.querySelectorAll("svg").forEach((item) => {
for (let path of item.children) {
paths.push(path);
}
});
function animation() {
if (paths[pathIndex]) {
let pathLength = paths[pathIndex].getTotalLength();
length += distancePerPoint;
paths[pathIndex].style.stroke = borderColor;
paths[pathIndex].style.strokeDasharray = [length + 1, pathLength].join(" ");
if (length >= pathLength) {
clearInterval(timer);
setTimeout(() => {
length = 1;
timer = setInterval(animation, 1000 / drawFPS);
pathIndex++;
}, 300);
}
}
}