PDA

View Full Version : Phonegap & Orientation Change - Only fires ounce



ed.canas
2 Nov 2010, 6:51 AM
I've already posted this as a reply on another tread but thought I give it a fresh start.
It seems that when you deploy a Sencha app via Phonegap or even Quickconnect(similar tool to phonegap) to an iphone/iPad, the orientation event stops working it only fires ounce if I start my app while the phone is in landscape mode it will properly set the correct width and heights.

By removing one pixel from the width on landscape mode seems to the fix the problem of it not firing anymore.
I've added the following code to kitchen sink app to test this, which works fine as long as I don't set the landscape width to the maximum. I believe the same problem happens with Sencha orientation event when it gets set to landscape and then using width set to maximum it also stops firing the orientation event change.



sink.Main = {
init: function() {
...
},

setOrientation: function() {
var width = (Ext.getOrientation()=="landscape") ? window.innerWidth-1 : window.innerWidth
this.ui.setOrientation( Ext.getOrientation(), width , window.innerHeight );

//this.ui.setOrientation( Ext.getOrientation() , window.innerWidth , window.innerHeight ); <-- This will make it fail and stop firing
},
.........

};


Ext.setup({
....
onReady: function() {
Ext.EventManager.onWindowResize(senchaChangeOrientation);
...

});

function senchaChangeOrientation() {
sink.Main.setOrientation();
}



It seems this is a Sencha problem since I've tried two different tools for deploying the app locally. I previously worked with jQTouch/Phonegap which did not have this problem when switching between portrait and landscape mode.

Any help on getting this looked at would be appreciated. Thanks.