vydimitrov/use-count-up

Can't count minutes

Closed this issue · 2 comments

<Text><CountUp isCounting={starTimer} start={0} end={180} duration={180} easing="linear"/></Text>
<Text><CountUp isCounting={starTimer} start={0} end={3} duration={180} easing="linear"/></Text>

If I am not mistaken, this two counters should end at the same time, but they don't.

Here's how it works:

The second timer turns to 1 when the first one is at 30.
The second timer turns to 2 when the first one is at 90
The second timer turns to 3 when the first one is at 150.

Am I doing something wrong or it is just not working when trying to count minutes?

Hey @Sefean, the timer is using internally Math.round to format the value (at 30 the value will be more than 0.5 thus rounded to 1 and so on). This works for most of the cases to make the number transition smooth. If you need a different output format, just pass your formatting function.

Ohh that's why, it was driving me crazy. Thanks!

PS: In case it helps anyone here's what I ended up doing:

<Text> <CountUp isCounting={starTimer} start={0} end={300} duration={300} easing="linear" formatter={(val) => { return Math.trunc(val/60) }} /> </Text>