ux/FlipCounter.js
[roojs1] / ux / FlipCounter.js
index 91f46d9..ca2aa0b 100644 (file)
@@ -53,12 +53,13 @@ Roo.extend(Roo.ux.FlipCounter, Roo.bootstrap.Component, {
         
     initEvents : function ()
     { 
-        var startNum = ""+ this.startnumber;
+        var startNum = (1.0*this.startnumber).toFixed(this.decimal);
         
         for (i=startNum.length-1; i>=0; i=i-1)
         {
             if (startNum[i] == '.') {
                 this.addSeparator('.');
+                continue;
             }
             this.addDigit(startNum[i]);
         }
@@ -97,20 +98,20 @@ Roo.extend(Roo.ux.FlipCounter, Roo.bootstrap.Component, {
         digit.el.remove();
         
         // Remove separators
-        if (this.digits.length % 3 == 0)
-        {
-            var comma = this.el.select('li.comma:first-child');
-            this.ulWidth = this.ulWidth - comma.getWidth(true);
-            comma.remove();
-        }
+       // if (this.digits.length % 3 == 0)
+      //  {
+          //  var comma = this.el.select('li.comma:first-child');
+          //  this.ulWidth = this.ulWidth - comma.getWidth(true);
+          //  comma.remove();
+        //}
         
         // Update width to current
         this.el.set( { 'min-width' : this.ulWidth});
     },
     
-    addSeparator : function (num)
+    addSeparator : function (str)
     {
-        var comma = this.el.insertHtml('afterBegin','<li class="comma">,</li>',true);
+        var comma = this.el.insertHtml('afterBegin','<li class="comma">'+str+'</li>',true);
         
         // Update width
         
@@ -120,13 +121,14 @@ Roo.extend(Roo.ux.FlipCounter, Roo.bootstrap.Component, {
     
     updateTo : function (num)
     {
-        var numStr = parseInt(num).toString();
+        var numStr = (1.0*num).toFixed(this.decimal);
         
         this.currentNumber = num;
         // Change the number of digits displayed if needed
         if (numStr.length != this.digits.length)
         {
             var diff = numStr.length - this.digits.length;
+            Roo.log("DIFF LEN=" +diff);
             if (diff > 0)
             {
                 for (i=0; i<diff; i=i+1) {
@@ -146,6 +148,10 @@ Roo.extend(Roo.ux.FlipCounter, Roo.bootstrap.Component, {
         // Change all digit values
         for (i=0; i<numStr.length; i=i+1)
         {
+            if (numStr[numStr.length - 1 - i] == '.') {
+                continue;
+            }
+            Roo.log("UPDATE DIGIT=" + i + " to " + numStr[numStr.length - 1 - i]);
             this.digits[i].flipTo(numStr[numStr.length - 1 - i]);
         }
     }