MCPcopy Create free account
hub / github.com/Cicada000/VV / startNaturalLoadingBar

Function startNaturalLoadingBar

Web/script.js:1080–1101  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1078 return null;
1079}
1080function startNaturalLoadingBar() {
1081 const loadingBar = document.getElementById("loadingBar");
1082 loadingBar.style.transition = "";
1083 loadingBar.style.width = "0%";
1084 loadingBar.style.display = "block";
1085 if (loadingBar.interval) clearInterval(loadingBar.interval);
1086 let progress = 0;
1087 const targetProgress = 95;
1088 let speed = 0.5;
1089 loadingBar.interval = setInterval(() => {
1090 if (progress < 30) speed = 0.8;
1091 else if (progress < 60) speed = 0.4;
1092 else if (progress < 80) speed = 0.2;
1093 else speed = 0.1;
1094 progress += speed;
1095 if (progress >= targetProgress) {
1096 clearInterval(loadingBar.interval);
1097 progress = targetProgress;
1098 }
1099 loadingBar.style.width = `${progress}%`;
1100 }, 50);
1101}
1102function completeLoadingBar() {
1103 const loadingBar = document.getElementById("loadingBar");
1104 clearInterval(loadingBar.interval);

Callers 1

handleSearchFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected