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

Number not showing exact number #47

Open nikunj1990 opened 7 years ago

nikunj1990 commented 7 years ago

Hello,

For eg. i added 60,056 and when it count and finish it shows 60,055 and 107,235 shows 107,234

nikunj1990 commented 7 years ago

we have resolved this issue...

for (var i = divisions; i >= 1; i--) {

            // Preserve as int if input was int
            **var newNum = Math.round(num / divisions * i);** // replace ParseInt with Math.round code in couter-up js

            // Preserve float if input was float
            if (isFloat) {
                newNum = parseFloat(num / divisions * i).toFixed(decimalPlaces);
            }

            // Preserve commas if input had commas
            if (isComma) {
                while (/(\d+)(\d{3})/.test(newNum.toString())) {
                    newNum = newNum.toString().replace(/(\d+)(\d{3})/, '$1'+','+'$2');
                }
            }

            nums.unshift(newNum);
        }
ciromattia commented 7 years ago

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

mcoirad commented 7 years ago

@nikunj1990 Thanks, you saved me with your fix. My problem happened to be with the number 205 showing up as 204.

@ciromattia I couldn't get your fork to work but that just might be something on my end.

itsKnight847 commented 6 years ago

@ciromattia you are life saver, updating the library solved it!