speed : 0.2,
startnumber : 0,
+ currentNumber : 0,
+ decimal : 0,
digits : false, // array...
- ulWidth : 0,
+ ulWidth : 0,
+ cls : '',
getAutoCreate : function(){
return {
tag: 'ul',
- cls: 'flipcounter',
+ cls: 'flipcounter ' + this.cls,
};
},
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('.');
+ }
this.addDigit(startNum[i]);
}
+ this.currentNumber = this.startnumber;
},
addDigit : function (num)
{
// Add separator after every 3rd digit
- if (this.digits.length % 3 == 0 && this.digits.length != 0)
+ /*if (this.digits.length % 3 == 0 && this.digits.length != 0)
{
- this.addSeparator();
+ this.addSeparator(',');
}
-
-
-
+ */
+
var digit = new Roo.ux.FlipCounter.Digit({ manager : this, currentNumber : num });
digit.manager = this;
{
var digit = this.digits.splice(this.digits.length-1, 1)[0];
- this.ulWidth = this.ulWidth - digit.el.outerWidth(true);
- digit.li.remove();
+ this.ulWidth = this.ulWidth - digit.el.getWidth(true);
+ 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
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)
{
- this.topFrontDiv = this.el.select('.flipper_top_front',true);
- this.bottomFrontDiv = this.el.select('.flipper_bottom_front',true);
- this.topNumBack = this.el.select('.flipper_top_back span',true);
- this.topNumFront = this.el.select('.flipper_top_front span',true);
- this.bottomNumBack = this.el.select('.flipper_bottom_back span',true);
- this.bottomNumFront = this.el.select('.flipper_bottom_front span',true);
+ this.topFrontDiv = this.el.select('.flipper_top_front',true).first();
+ this.bottomFrontDiv = this.el.select('.flipper_bottom_front',true).first();
+ this.topNumBack = this.el.select('.flipper_top_back span',true).first();
+ this.topNumFront = this.el.select('.flipper_top_front span',true).first();
+ this.bottomNumBack = this.el.select('.flipper_bottom_back span',true).first();
+ this.bottomNumFront = this.el.select('.flipper_bottom_front span',true).first();
this.targetNum = this.currentNumber;
this.currentNum = this.currentNumber;
scaleY: {from: 0, to : 1},
},
- this.manager.options.speed * 0.5, //duration
+ this.manager.speed * 0.5, //duration
function() {
digit.currentNum = digit.nextNum;
digit.topNumFront.dom.innerHTML = digit.currentNum;