terminado banner fidelidad

This commit is contained in:
2026-02-08 12:32:44 +01:00
parent 61e55e014f
commit 1bfe0cf3a2
7 changed files with 440 additions and 2250 deletions

View File

@ -0,0 +1,34 @@
import {formateaMoneda} from "./utils.js";
$(() => {
// Contador animado
function counter() {
var counter = document.querySelectorAll(".counter-value");
var speed = 250; // The lower the slower
counter &&
Array.from(counter).forEach(function (counter_value) {
function updateCount() {
var target = +counter_value.getAttribute("data-target");
var count = +counter_value.innerText;
var inc = target / speed;
if (inc < 1) {
inc = 1;
}
// Check if target is reached
if (count < target) {
// Add inc to count and output in counter_value
counter_value.innerText = (count + inc).toFixed(0);
// Call function every ms
setTimeout(updateCount, 1);
} else {
counter_value.innerText = formateaMoneda(target);
}
formateaMoneda(counter_value.innerText);
}
updateCount();
});
}
counter();
})