Results 1 to 6 of 6

Thread: Change layout on orientation change

  1. #1
    Sencha User
    Join Date
    Feb 2012
    Location
    netherlands
    Posts
    11
    Vote Rating
    0
      0  

    Default Answered: Change layout on orientation change

    Hey all, a common thing I guess but I haven't found a solution.

    I've got a panel with a hbox layout. When the orientation is changed to portrait I want the items underneath eachother, and so change the layout of the panel to vbox.

    I listen to the orientation event and execute this code:
    Code:
            
    handleOrientationChange: function(viewport, orientation, width, height) {
            var layout = (orientation == 'landscape') ? 'hbox' : 'vbox';
            this.getPage().setLayout(layout);
            console.log('layout set to ' + layout + ', ' + orientation);
            console.log(this.getPage());
        }
    In the console I see the layout property of the page is changed well, but the view isn't responding to it, I don't see anything change.

    Can anyone point me out what I'm doing wrong?

  2. Quote Originally Posted by mitchellsimoens View Post
    Changing layouts on the fly are supported fully currently.
    This would involve evaluating the DOM structure and add/delete/update the DOM elements to change the layout which is not currently supported natively. The JavaScript may be changed but the DOM may not be changed.

  3. #2
    Sencha - Community Support Team mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,020
    Answers
    3976
    Vote Rating
    1363
      0  

    Default

    Changing layouts on the fly are supported fully currently.
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Frontend Engineer
    ________________
    Need any sort of Ext JS help? Modus Create is here to help!

    Check out my GitHub:
    https://github.com/mitchellsimoens

  4. #3
    Sencha User
    Join Date
    Feb 2012
    Location
    netherlands
    Posts
    11
    Vote Rating
    0
      0  

    Default

    Thank you for the reply Mitchell. But in that case, the code I posted earlier should work?

    Do I have to update the component in some sort of way perhaps? Because I can't get it to work.
    More of the code from the controller:

    Code:
    createPage: function(orientation) {    	
         	var layout = (orientation == 'landscape') ? 'hbox' : 'vbox';
            
            var page = Ext.create('Ext.Panel', {
            	layout: layout,
            	id: 	'gallery',
            	items: [
            		{xtype: 'panel', html: 'one', flex: 1},
            		{xtype: 'panel', html: 'two', flex: 1},
            	],
            });       
    
    
            this.getPageContainer().setActiveItem(page);
        },
        
        
        handleOrientationChange: function(viewport, orientation, width, height) {
    		var layout = (Ext.Viewport.getOrientation() == 'landscape') ? 'hbox' : 'vbox';
    		this.getPage().setLayout(layout);
    		
    		console.log(this.getPage().getLayout());
        }
    As said, the console logs the correct layout of the page.

  5. #4
    Sencha - Community Support Team mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,020
    Answers
    3976
    Vote Rating
    1363
      0  

    Default

    Quote Originally Posted by mitchellsimoens View Post
    Changing layouts on the fly are supported fully currently.
    This would involve evaluating the DOM structure and add/delete/update the DOM elements to change the layout which is not currently supported natively. The JavaScript may be changed but the DOM may not be changed.
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Frontend Engineer
    ________________
    Need any sort of Ext JS help? Modus Create is here to help!

    Check out my GitHub:
    https://github.com/mitchellsimoens

  6. #5
    Sencha User
    Join Date
    Feb 2012
    Location
    netherlands
    Posts
    11
    Vote Rating
    0
      0  

    Default

    Hey Mitchell, thanks for the reaction. That made the differences clear to me.

    Now I remove the component from the DOM first and add it again, solves the problem for me

  7. #6
    Sencha User
    Join Date
    Mar 2007
    Posts
    443
    Answers
    5
    Vote Rating
    18
      0  

    Default

    Quote Originally Posted by mitchellsimoens View Post
    Changing layouts on the fly are supported fully currently.
    I assume you mean not supported.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •