Skip to content

Instantly share code, notes, and snippets.

@mauropm
Created July 4, 2013 05:40

Revisions

  1. Mauro Parra-Miranda created this gist Jul 4, 2013.
    57 changes: 57 additions & 0 deletions app.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,57 @@
    var win = Ti.UI.createWindow({
    backgroundColor:'white',
    });

    // *** This is taken from Dawsontoth's https://gist.github.com/dawsontoth/839218
    var rotate = Ti.UI.create2DMatrix().rotate(90);
    var counterRotate = rotate.rotate(-180);
    // *** end of the code taken from Dawsontoth's

    function randomInt(min, max) {
    return Math.round(min + Math.random()*(max-min));
    }

    function getView(){
    var rnd = randomInt(0,200) % 3;
    var color = 'black';
    switch(rnd){
    case 0:
    color='gray';
    break;
    case 1:
    color='pink';
    break;
    case 2:
    color='yellow';
    break;
    default:
    color='black';
    break;
    }
    return Ti.UI.createView({
    backgroundColor:color,
    top:0,
    left:0,
    height: Ti.UI.FILL,
    weight: Ti.UI.FILL,
    transform:counterRotate,
    });
    }

    var autoscroll = Ti.UI.createScrollableView({
    showPagingControl:false,

    height: 320,
    width: 480,
    transform:rotate,
    });

    for(i=0;i<10;i++){
    autoscroll.addView(getView());
    }

    setInterval(function(){autoscroll.removeView(0); Ti.API.info("Removed head");},3000);
    setInterval(function(){autoscroll.addView(getView()); Ti.API.info("Added view");},2500);

    win.add(autoscroll);
    win.open();