Skip to content

counter

import { createCounter, formatNumber } from "hyperbits/helpers";
const { proxy, apply } = createCounter(valueEl, {
from: 0,
decimals: 0,
separator: ",",
prefix: "$",
});
timeline.to(proxy, { value: 1280, duration: 2, onUpdate: apply }, 0);
OptionDefault
decimals0
separator""
decimal"."
prefix""
postfix""

Returns { proxy, apply }. proxy.value is the live number. apply() writes formatNumber(proxy.value) into element.textContent.