-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBar.js
57 lines (48 loc) · 1.75 KB
/
Bar.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
const loading = document.getElementById("loading");
const number1 = document.getElementById("number1");
const number2 = document.getElementById("number2");
const circle = document.querySelector("circle");
const loadingDots = ['.', '..', '...'];
let loadingCounter = 0;
let numberCounter1 = 0;
let numberCounter2 = 0;
// Function to update the loading dots
function updateLoadingDots() {
if (loadingCounter === loadingDots.length) {
loadingCounter = 0;
}
loading.textContent = loadingDots[loadingCounter];
loadingCounter++;
}
// Function to update the number counter 1 and adjust the progress bar
function updateNumberCounter1() {
if (numberCounter1 === 65) {
clearInterval(numberInterval1);
} else {
numberCounter1++;
number1.innerHTML = numberCounter1 + "%";
updateProgressBar(numberCounter1);
}
}
// Function to update the number counter 2 and adjust the progress bar
function updateNumberCounter2() {
if (numberCounter2 === 74) {
clearInterval(numberInterval2);
} else {
numberCounter2++;
number2.innerHTML = numberCounter2 + "%";
}
}
// Function to update the progress bar based on the percentage
function updateProgressBar(percent) {
const circumference = circle.getTotalLength();
const offset = circumference * (1 - percent / 100);
circle.style.strokeDasharray = circumference;
circle.style.strokeDashoffset = offset;
}
// Interval for updating the loading text
const loadingInterval = setInterval(updateLoadingDots, 500);
// Interval for updating the number counter 1 and progress bar
const numberInterval1 = setInterval(updateNumberCounter1, 25);
// Interval for updating the number counter 2
const numberInterval2 = setInterval(updateNumberCounter2, 32);