Hybrid View

    Success! Looks like we've fixed this one. According to our records the fix was applied for TOUCH-505 in a recent build.
  1. #1
    Touch Premium Member jongohr's Avatar
    Join Date
    Mar 2007
    Location
    Lakeville, MN
    Posts
    39
    Vote Rating
    0
    jongohr is on a distinguished road

      0  

    Default Spinner Bug

    Spinner Bug


    Touch 1.1.0

    Have a spinner configured like this.

    Code:
    new Ext.form.Spinner({
                                name: 'alpha',
                                label: 'Level',
                                minValue: .2,
                                maxValue: 4.0,
                                incrementValue: .1,
                                value: 1.0,
                                cycle: true
                            })
    First click of the '+' button increments to 1.1 and the next click of the '+' button increments to 1.2000000000000002
    Jon

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,756
    Vote Rating
    828
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    I typed this in the Chrome WebKit Inspector:

    Code:
    1.1 + 0.1
    And it echoed 1.200000000002 so it appears that this isn't a Sencha Touch bug but something that may need to be looked in to. Possibly need a format config like in Ext JS which would be a workaround.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,756
    Vote Rating
    828
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Found out that this is a JS thing using IEEE numbers which is why there are lots of "noise" in the value. The value is technically correct but not what is expected.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  4. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,756
    Vote Rating
    828
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      1  

    Default


    Not sure if this is going to be what we will do (or if we do anything ).

    Ext JS 3 has a number method on Ext.util.Format so I ported that over:

    Code:
    Ext.util.Format.number = function(v, format) {
        if (!format) {
            return v;
        }
        v = Ext.num(v, NaN);
        if (isNaN(v)) {
            return '';
        }
        var comma = ',',
            dec   = '.',
            i18n  = false,
            neg   = v < 0;
    
        v = Math.abs(v);
        if (format.substr(format.length - 2) == '/i') {
            format = format.substr(0, format.length - 2);
            i18n   = true;
            comma  = '.';
            dec    = ',';
        }
    
        var hasComma = format.indexOf(comma) != -1,
            psplit   = (i18n ? format.replace(/[^\d\,]/g, '') : format.replace(/[^\d\.]/g, '')).split(dec);
    
        if (1 < psplit.length) {
            v = v.toFixed(psplit[1].length);
        } else if(2 < psplit.length) {
            throw ('NumberFormatException: invalid format, formats should have no more than 1 period: ' + format);
        } else {
            v = v.toFixed(0);
        }
    
        var fnum = v.toString();
    
        psplit = fnum.split('.');
    
        if (hasComma) {
            var cnum = psplit[0],
                parr = [],
                j    = cnum.length,
                m    = Math.floor(j / 3),
                n    = cnum.length % 3 || 3,
                i;
    
            for (i = 0; i < j; i += n) {
                if (i != 0) {
                    n = 3;
                }
    
                parr[parr.length] = cnum.substr(i, n);
                m -= 1;
            }
            fnum = parr.join(comma);
            if (psplit[1]) {
                fnum += dec + psplit[1];
            }
        } else {
            if (psplit[1]) {
                fnum = psplit[0] + dec + psplit[1];
            }
        }
    
        return (neg ? '-' : '') + format.replace(/[\d,?\.?]+/, fnum);
    };
    So I am setting up the Spinner field like this (important line in red & bold):

    Code:
    var form = new Ext.form.FormPanel({
        fullscreen : true,
        items      : [
            {
                xtype          : 'spinnerfield',
                label          : 'Test',
                minValue       : 0.2,
                maxValue       : 4,
                incrementValue : 0.1,
                value          : 1,
                format         : '0.0',
                cycle          : true
            }
        ]
    });
    So now to bring it altogether, here is the actual override to get this to work:

    Code:
    Ext.form.Spinner.override({
        setValue : function(value) {
            value = parseFloat(value);
    
            var format = this.format;
    
            if (format) {
                value = Ext.util.Format.number(value, format);
            }
    
            if (isNaN(value)) {
                value = this.defaultValue;
            }
    
            Ext.form.Number.prototype.setValue.call(this, value);
        }
    });
    Let me know if this works for you For docs on different formats to use in Ext.util.Format.number, look at the Ext JS 3.x API docs: http://dev.sencha.com/deploy/ext-3.4...xt.util.Format
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  5. #5
    Sencha User
    Join Date
    Sep 2011
    Posts
    9
    Vote Rating
    0
    vitorgomes is on a distinguished road

      0  

    Default Works for me!

    Works for me!


    Hi Mitchell,

    I was having the same problem.
    I added the code to my app.js and it's working pretty well.

    Thanks!
    Vitor

  6. #6
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,756
    Vote Rating
    828
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Quote Originally Posted by vitorgomes View Post
    Hi Mitchell,

    I was having the same problem.
    I added the code to my app.js and it's working pretty well.

    Thanks!
    Vitor
    Fantastic!
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi