export const animateValue = (obj, start = 0, end = 100, duration = 1000, numberFormat = 'Sv-SE', formatStyle) => {
    const formatter = new Intl.NumberFormat(numberFormat, formatStyle);
    if (duration <= 0) {
        obj.textContent = formatter.format(end);
        return;
    }
    let startTimestamp = null;
    const step = (timestamp) => {
        if (!startTimestamp)
            startTimestamp = timestamp;
        const progress = Math.min((timestamp - startTimestamp) / duration, 1);
        if (progress < 1) {
            const animatedValue = Math.round((progress * (end - start) + start) * 10) / 10;
            obj.textContent = formatter.format(animatedValue);
            window.requestAnimationFrame(step);
        }
        else {
            obj.textContent = formatter.format(end);
        }
    };
    window.requestAnimationFrame(step);
};
//# sourceMappingURL=animationHelper.js.map
