View Full Version : A panel has x-portrait and x-landscape at the same time.

14 Mar 2011, 5:26 AM
I want to change the panel's look based on the orientation so I used .x-portrait .class1 / .x-landscape .class1... but it didn't show what I expected.

I found the problem after the first orientation the panel has x-portrait and x-landscape at the same time. This is why.

1. Run the application.
'x-portrait' is added in onRender() but this.orientation is undefined.
2. Rotate to landscape
in setOrientation(), removeCls('x-' + this.orientation) called but 'x-portrait' is still remained because this.orientation is still undefined.
3. After that
this.orientation is set correctly.

To solve this, I changed the source a little bit.

onRender: function() {
if (this.monitorOrientation) {
this.orientation = Ext.Viewport.orientation; // added. set this.orientation here for good.
this.el.addCls('x-' + Ext.Viewport.orientation);

I'm not sure this fix doesn't cause any side effect, but it seems ok so far.

21 Jun 2011, 10:34 AM
Hi Norabora,

I've noticed the same issue.

Nice fix - appears to work.