bfintal / Counter-Up

Counter-Up is a lightweight jQuery plugin that counts up to a targeted number when the number becomes visible.
http://bfintal.github.io/Counter-Up/demo/demo.html
GNU General Public License v2.0
746 stars 722 forks source link

ending up with different number than starting one #38

Open prk3 opened 7 years ago

prk3 commented 7 years ago

example input for reproducing this bug: html number: 2014 delay: 10 time: 3000

this bug is caused by parsing numbers to int instead of rounding them. just replace parseInt with Math.round.

dispa commented 7 years ago

I have the same problem: number: 29 delay: 10 time: 1000

I fixed this bug by replacing line 40 var newNum = parseInt(num / divisions * i); with: (num / divisions * i).toFixed();

I hope this helps you

zur4ik commented 7 years ago

Had same problem and that made me crazy. Only 29 had this problem :+1:

ciromattia commented 7 years ago

It should be fixed in my fork, can you tell me if it's working for you? Thanks!

zur4ik commented 7 years ago

@ciromattia yes, @dispa's fix solved the problem

dispa commented 7 years ago

yes, fixed