This commit is contained in:
salam committed 2026-06-17 12:42:43 +02:00
1 parent 3376eb6d2e
commit ec60adb074
9 files changed
+194 -195

No files matched your search

+4 -8
View File
@@ -1,5 +1,5 @@
function animate(element, end, fixtotwo) {
// console.log(element, end);
function animate(element, end, duration = 500) {
console.log(element, end);
var element = document.getElementById(element);
const startTime = performance.now();
@@ -10,7 +10,7 @@ function animate(element, end, fixtotwo) {
const updateCount = (currentTime) => {
const elapsedTime = currentTime - startTime;
let progress = elapsedTime / 500;
let progress = elapsedTime / duration;
// Clamp progress to ensure it doesn't overshoot
if (progress > 1) progress = 1;
@@ -21,11 +21,7 @@ function animate(element, end, fixtotwo) {
// Calculate current value and round to integer
const currentCount = Math.round(end * easedProgress * 100) / 100;
if (fixtotwo) {
element.innerHTML = currentCount.toFixed(2);
} else {
element.innerHTML = currentCount;
}
element.innerHTML = currentCount;
if (progress < 1) {
requestAnimationFrame(updateCount);