javascriptjqueryodometer

Need to find a javascript fix for this odometer "counter" from hubspot


I've looked around for a while now and tried many different fixes. I have the odometer working correctly, (counting up as it should) but when it hits a number with a zero at the end the odometer loses the last decimal place. I have toFix() which I assumed would work but not. I have it all set up on this fiddle.

The fiddle http://jsfiddle.net/mb91t1Ln/4/

This is where I got the plug in from: http://github.hubspot.com/odometer/

var placement = document.querySelector('.odometer');
var startValue = placement.innerHTML;
var increase = 0.01;
var seconds = $('.odometer').data("seconds");
var speed = (1 / seconds) * 10;

jackpotOdometer = new Odometer({        
    el: placement,
    value: startValue,
    format: '(,ddd).dd'
});

var current = jackpotOdometer.value;
//console.log("current = " + current);

setInterval(function(){
    //var parsed = parseInt(increase);      
    //jackpotOdometer.update(current + increase);
    //var fixedCurrentNumber = currentPlusIncrease.toFixed(2);
    //console.log("Fixed Current Number = " + fixedCurrentNumber);
    //current = current.toFixed(2) + increase.toFixed(2);

    var num = (current += increase).toFixed(2);
    console.log("current = " + num);
    jackpotOdometer.update(num);
}, speed);

Solution

  • It's a known issue and there's a temporary patched version running around..

    https://github.com/HubSpot/odometer/issues/63