Counter Issue with JavaScript engine
-
Hi,
We found an issue in your Counter Up Block. Due to the way JavaScript handle small numbers, your Count Up Block is a little buggy with certain integers. For example: 228 / 100 * 100 give as a result : 227.9999999997 and get rounded to 227 by the “parseInt” method.
Perhaps your should use a “Math.round” instead of the “parseInt”.
If the use of parseInt is mandatory for you, simply invert the calculation ( “i * f / n” instead of “i / n * f” ) should limit the “buggy cases”.We saw it depends on a library you use (jQuery count up by Benjamin Intal). Maybe you should update this library in your package because it’s pretty old.
Best regards
- The topic ‘Counter Issue with JavaScript engine’ is closed to new replies.