function animateValues(elems) {
elems = Array.from(elems);
const endValues = elems.map(el => Number(el.dataset.value));
const currValues = new Array(elems.length).fill(0);
function loop() {
let doneCount = 0;
for (let i = 0; i < elems.length; i++) {
if (currValues[i] === endValues[i]) {
doneCount++;
}
else {
currValues[i]++;
elems[i].innerText = currValues[i];
}
}
if (doneCount !== elems.length) setTimeout(loop, 20);
}
setTimeout(loop, 0);
}
function zoom(e) {
const zoomer = e.currentTarget;
let offsetX, offsetY;
if (e.touches) {
offsetX = e.touches[0].pageX;
offsetY = e.touches[0].pageY;
} else {
offsetX = e.offsetX;
offsetY = e.offsetY;
}
const x = offsetX/zoomer.offsetWidth*100
const y = offsetY/zoomer.offsetHeight*100
zoomer.style.backgroundPosition = x + '% ' + y + '%';
}