Open Guaito opened 9 years ago
Hi,
I was looking for this, too. Since I saw there was not much of feedback, I thought I'd look for it myself.
Might not be the most suitable solution, but I've added:
newNum = newNum.replace(/\./g, settings.commaSeparator);
after:
newNum = parseFloat(num / divisions * i).toFixed(decimalPlaces);
inside the if (isFloat) {}
-statement.
I've also added a couple of parameters to the settings for re-use, which you can adjust whenever you call the function:
// Defaults
var settings = $.extend({
'time': 400,
'delay': 10,
'commaSeparator': '.',
'thousandSeparator': ','
}, options);
In my fork I merged a bunch of PRs - it's already on bower and NPM. You can get this with the new "formatter" option, for example if you have no decimals:
$('.counter').counterUp({
delay: 100,
time: 1600,
formatter: function (n) {
return n.replace(/,/g, '.');
});
Feel free to mangle the regex for decimal support.
Can you manage also the european number format (opposite to english) in terms of "." and "," inside numbers? i.e.:
Thanks in advance