1. #1
    Sencha User
    Join Date
    Apr 2012
    Posts
    33
    Vote Rating
    0
    wiwi is on a distinguished road

      0  

    Default Orientation Landscape & Portrait

    Orientation Landscape & Portrait


    Hello, I'm using Sencha Touch 2, and I was looking at the sencha docs how to change the layout size after orientation changes, actually I found only this example,
    Ext.device.Orientation.on({
    scope: this,
    orientationchange: function(e) {
    console.log('Alpha: ', e.alpha);
    console.log('Beta: ', e.beta);
    console.log('Gamma: ', e.gamma);
    }
    });
    and it seems not clear enough for me as I have to implement orientation changes on my app , any help will be so kind, thanks in advance.

  2. #2
    Sencha - Community Support Team sword-it's Avatar
    Join Date
    May 2012
    Location
    Istanbul
    Posts
    1,333
    Vote Rating
    85
    sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough

      0  

    Default


    Hi wiwi,

    Orientation change is handled by the Viewport, Essentially, on the initialization of a Panel, you add a listener (where on is an alias for addListner ) to the panel. From there, you create a new method called 'handleOrientationChange` (or whatever you want to call it) that will execute when the Viewport Orientation Changed


    Code:
    Ext.define('app.view.home.indexView', {
        extend: 'Ext.Panel',
        alias: 'widget.home-indexView',
        config: { 
            //...
        },
        // Fires when the Panel is initialized
        initialize: function () {
            console.log('app.view.home.indexView ~ initialize');
            // Add a Listener. Listen for [Viewport ~ Orientation] Change.
            Ext.Viewport.on('orientationchange', 'handleOrientationChange', this, {buffer: 50 });
            this.callParent(arguments);
        },
        handleOrientationChange: function(){
            console.log('rpc.view.home.indexView ~ handleOrientationChange');
            // Execute the code that needs to fire on Orientation Change.
        }
    };


    For more detail see

    http://www.developria.com/2010/11/ma...ware-apps.html
    sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.

  3. #3
    Sencha User
    Join Date
    Apr 2012
    Posts
    33
    Vote Rating
    0
    wiwi is on a distinguished road

      0  

    Default


    Hi sword-it,

    Appreciating your help, in fact I have created a master view (in the root app folder), in witch I'm calling models, stores, controllers(php files), and profiles for iphone and ipad, so the second view is defined in every subdirectory of each profile(phone, tablet), it's called depending on the device, I just don't get where I have to put the listenners, functions and alias,
    I'm in troubles .

  4. #4
    Sencha - Community Support Team sword-it's Avatar
    Join Date
    May 2012
    Location
    Istanbul
    Posts
    1,333
    Vote Rating
    85
    sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough

      0  

    Default


    Ext.Viewport fires an orientationchnage event you can use xtype 'viewport' in your controller to listen Ext.Viewport under control config Like-
    Code:
    Ext.define('App.controller.tablet.Main', { 
       extend: 'Ext.app.Controller', 
           config: { 
           refs: {  
              viewport: 'viewport', 
           }, 
           control: { 
               viewport: { 
                   orientationchange: 'handleOrientationChange' 
               }
            }
        }, 
       init: function(){
            this.callParent(arguments);
        },
        handleOrientationChange: function(viewport, orientation, width, height){ 
       var realOrientation = Ext.Viewport.determineOrientation();                     console.log(realOrientation); //echos portrait or landscape respectively
        }
    });
    See this thread http://www.sencha.com/forum/showthre...ntation-Change
    sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.

  5. #5
    Sencha User
    Join Date
    Apr 2012
    Posts
    33
    Vote Rating
    0
    wiwi is on a distinguished road

      0  

    Default


    Actually you answer helped me a lot, now I can see an event after changing the phone orientation,
    Ext.define('applmlm.controller.phone.main', {
    extend: 'Ext.app.Controller',
    config: {
    refs: {
    viewport: 'viewport',
    },
    control: {
    viewport: {
    orientationchange: 'handleOrientationChange'
    }
    }
    },
    init: function(){
    this.callParent(arguments);
    }
    ,
    handleOrientationChange: function(viewport, orientation, width, height){
    var realOrientation = Ext.Viewport.determineOrientation();
    console.log(realOrientation);

    if(orientation == Ext.Viewport.PORTRAIT){
    //show toolbars
    // this.down('toolbar[cls=topToolbar]').show();
    alert('Portrait');
    } else {
    //hide toolbars
    // this.down('toolbar[cls=topToolbar]').hide();
    alert('Landscape');
    }
    }
    });

    I've tested it with alert, because hiding or showing toolbars doesn't seems working, I have some lists and buttons, that I have to resize, can I do that with Ext.getCmp('id').resize(); ???

Thread Participants: 1

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..."