mirror of
https://git.imnavajas.es/jjimenez/erp-imprimelibros.git
synced 2026-02-10 21:09:12 +00:00
terminado banner fidelidad
This commit is contained in:
@ -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();
|
||||
|
||||
})
|
||||
Reference in New Issue
Block a user