Simple counter built in js
npm install @federico.mameli/counter
or
yarn add @federico.mameli/counter
import Counter from '@federico.mameli/counter'
const counterEl = document.querySelector('.counter')
const counter = new Counter({
el: counterEl,
from = 0,
to = 100,
incRange = 10,
overflow = 0,
time = 50,
start = false
})
counter.start()
The element where to print the counter values.
start value, default 0
end value, default 100
value added each time
default is 0, if a percentage is defined the counter will count until to + (to * overflow)
and will count down until to
.
velocity of each change, default 50 ms
if true starts the counter
Start the counter